关闭联系表格7上的Boostrap模式提交

时间:2015-05-14 21:48:19

标签: jquery bootstrap-modal contact-form-7

在Bootstrap模式中,我有一个联系表格7。 发送邮件后我无法关闭模态。 你要做的是转到"动作"的链接。表格的属性。 我无法删除"动作"动态创建的属性。 也许解决方案可能是使用" event.preventDefault()"用" on_sent_ok"。 但不是如何。

Working Example

点击一个备注,然后点击 Compartir ,然后点击邮件图标

4 个答案:

答案 0 :(得分:1)

不,我把代码放在模态中。在模态体中只需<?php echo do_shortcode( '[the contact form 7 shortcode]' ); ?>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        <?php echo do_shortcode( '[the contact form 7 shortcode]' ); ?>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

答案 1 :(得分:1)

我的解决方案,我也有提交按钮点击事件的引导按钮。

on_sent_ok: "setTimeout("$('button.submit').prop('disabled', null).button('reset'); $('.modal').modal('hide');", 3000); 
ga('send', 'event', 'Купить быстро', 'Submit');"

此代码应放在编辑联系表单页面的其他设置选项卡中

答案 2 :(得分:0)

我用这段代码找到了我的解决方案。表单提交时,Modal会在1秒后关闭。

j(".form-horizontal").live("submit", function(){
        j.post(this.action, j(this).serialize(), function(){
            //this callback is executed upon success full form submission close modal here

        }, "script");
     //this is to wait 1 second until close
        setTimeout(function() {j('.modal').modal('hide');}, 1000);          
        return false;
    });

答案 3 :(得分:0)

  • 将此代码粘贴到您的functions.php
add_action( 'wp_footer', 'submit_cf7' );
function submit_cf7() {
    ?>
    <script>
        document.addEventListener( 'wpcf7mailsent', function( event ) {
            if ( event.detail.contactFormId == '36' ) {
                setTimeout(function(){
                    jQuery('#contactModal').modal('hide');
                }, 2000);
            }
        }, false );
    </script>
    <?php
}

其中 36 - 您的表单 ID。模态窗口将在 2 秒后关闭

相关问题