我正在wordpress中使用elementor的弹出窗口来显示我的CF7表单。我的问题是,弹出窗口在显示提交后的确认文本之前会关闭。 在这种情况下我该怎么办?该文本非常重要。
答案 0 :(得分:0)
打开弹窗后需要重新初始化表单。
您可以在弹出窗口打开的页面中添加一个 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' );