Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling AJAX on Contact Form 7 Form after AJAX Load

I've tried searching but this only returns results on how to AJAX load a page/form. What I am doing is loading a form via AJAX (Contact Form 7) and I would like to know how to re-enable AJAX submission on that form. Is this a possibility with CF7?

like image 216
PavKR Avatar asked Mar 04 '15 22:03

PavKR


1 Answers

Use the following code for version 5.4 or above:

document.querySelectorAll(".wpcf7 > form").forEach((
                function(e){
                    return wpcf7.init(e)
                }
            )
        );

Put this in your ajax response. This will re-initialize all forms

like image 96
Joseph Ledesma Gabito Avatar answered Nov 02 '22 23:11

Joseph Ledesma Gabito