提交文字后,弹出窗口在显示联系表单7之前关闭

问题描述

我正在wordpress中使用elementor的弹出窗口来显示我的CF7表单。我的问题是,弹出窗口在显示提交后的确认文本之前会关闭。 在这种情况下我该怎么办?该文本非常重要。

解决方法

打开弹窗后需要重新初始化表单。

您可以在弹出窗口打开的页面中添加一个 html 小部件(或者在页脚中,如果在网站的任何部分打开)并粘贴以下代码:

<script>
// More information about elementor popup events 
// here https://developers.elementor.com/elementor-pro-2-7-popup-events/
jQuery( document ).on( 'elementor/popup/show',() => {
wpcf7.init(jQuery(".wpcf7-form")[0]);
});
</script>

甚至修改functions.php(如果需要,在子主题中):

// Stop Elementor Popup from Closing after CF7 submission with no validation
function elementor_popup_cf7_fix() {
?>
<script type='text/javascript'>
jQuery( document ).on( 'elementor/popup/show',() => {
    for(var i = 0; i < jQuery(".wpcf7-form").length ; i++)    {
     wpcf7.init(jQuery(".wpcf7-form")[i]);   
    }
});

</script>
<?php
}
add_action( 'wp_footer','elementor_popup_cf7_fix' );

来源:https://github.com/elementor/elementor/issues/7798

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...