Forums

[Plugin: Contact Form 7] Bind .ajaxForm after loading form via AJAX (2 posts)

  1. Earthman Web & Media Consulting
    Member
    Posted 11 months ago #

    I am loading my page contents using AJAX, so even though the Javascript for ContactForm7 is loaded in the footer, since the page contents and the Contact Form is loading via AJAX, the $('div.wpcf7 > form').ajaxForm (line 10) function is not binding properly.

    Does anyone know of a way that I can bind the form dynamically after/during the AJAX call, please? (ideally without hacking the ContactForm7 plugin core - I can modify the AJAX call for the pageload all I want - I am using a customized version of the plugin "AJAX page loader 1.5" for that)

    The test site is located at: knome.earthman.ca (load the contact page from the homepage via ajax with the menu link)

  2. seavan
    Member
    Posted 3 weeks ago #

    hello,

    you must execute script that binds all events on your contact form each time you add it to DOM tree, if you are making it AJAX-way.

    the simplest method is to include the following code:

    <script src="/wp-content/plugins/contact-form-7/scripts.js"></script>

    in your contact form template

    or add

    jQuery.get('/wp-content/plugins/contact-form-7/scripts.js', function(data) { eval(data); });

    after you have added the form to the DOM tree

Reply

You must log in to post.

About this Topic