• Resolved lagunawebdesign

    (@lagunawebdesign)


    It would be nice to have some JS events: init() | destroy() to manually trigger/reinit Your plugin after Ajax call in next update.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jules Colle

    (@jules-colle)

    Great idea! I will look into this

    Plugin Author Jules Colle

    (@jules-colle)

    I’ve been thinking about this for a while, but I’m not completely clear on the use case. If you are talking about an ajax enabled theme, simply calling init() after a form is loaded via ajax will probably not work, as the plugin uses wp_localize_scripts() to pass form specific variables for all the forms initially loaded on the page, but not for forms that might load afterwards via ajax.

    Anyway, in order to work on this I would need to test this with some kind of ajax enabled theme or plugin. Since you are asking this question my guess is you are aware of such a theme/plugin. If you could share it, I could try and figure out how to make the plugin compatible with it.

    Thread Starter lagunawebdesign

    (@lagunawebdesign)

    I use ajax to load form (.../wp-admin/admin-ajax.php?action=...), after js ajax load:

    //wpcf7
    if ($.fn.wpcf7InitForm) {
    // form 7...
        $('div.wpcf7 > form').wpcf7InitForm();
    // other JS functions...
        datePicker_init();
         _autoComplete();
    //...
    }

    Why php shortcodes [/group] isn’t working after ajax call?

    In cf7cf.php line 289 is blocking condition:
    if (!is_admin()) { // TODO: kind of hacky. maybe find a better solution. Needed because otherwise the group tags will be replaced in the editor as well.
    You can replace it… if (!is_admin() || (defined(‘DOING_AJAX’) && DOING_AJAX)) {

    Thread Starter lagunawebdesign

    (@lagunawebdesign)

    The same condition is in function wpcf7cf_enqueue_scripts(WPCF7_ContactForm $cf7form) {
    When I remove it and add <?php echo wp_footer(); ?> in my ajax view – it’s working without modifying JS, but.. for multiple forms load it’s not working beacourse You use not unique ID for options $wpcf7cf_global_count (inline JS before body end tag).

    It would be better to set options in data- attribute in form 7 tag (<form .. data-cf7-cf="..{"form_id":"410","unit_tag":"wpcf7-f410-o1","conditions":[{"if_field..." ...>, and in JS do $(‘form’).each(… to get and set data…
    or after form tag in some span element, like:

    <form ...> ... </form><span data-cf7-cf="..{"form_id":"410","unit_tag":"wpcf7-f410-o1","conditions":[{"if_field..."></span>
    and in JS do $(‘form’).each(… $(this).next().data(‘cf7-cf’) …to get and set data…

    Plugin Author Jules Colle

    (@jules-colle)

    I like your idea of including the data in the actual form. I always thought the wp_localize_script handle is a hassle to use and the way I’m figuring out the form unit-tags is pretty ugly as well. Stuffing it all in hidden fields inside the form might be a solution, but it’s a pretty big change so don’t expect an update too soon. Thanks!

    Plugin Author Jules Colle

    (@jules-colle)

    Hey, I modified the code so the form info is saved in a hidden field in the form itself. Can you make the ajax stuff happen now? What other changes would you suggest? I’d love your feedback on this.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Ajax support’ is closed to new replies.