Search code examples
jquerybootstrap-modalcontact-form-7

Close Boostrap Modal on Contact Form 7 submit


In a Bootstrap Modal, I have a Contact Form 7. I can not make the Modal is closed after sending the mail. What you do is go to the link of the "action" attribute of the form. I can not delete the "action" attribute that is created dynamically. Perhaps a solution might be to use "event.preventDefault ()" with "on_sent_ok". But not how.

Working Example

Click in one note, then in Compartir , and then in de Mail icon


Solution

  • I found my solution with this code. When form submit, the Modal closes after 1 second.

    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;
        });