Forums › Forums › Search & Filter Pro › CF7 and S&F – form action
- This topic has 19 replies, 3 voices, and was last updated 5 years, 7 months ago by
Anonymous.
-
Ross Moderator(Private) August 1, 2019 at 3:36 pm #217801
Hi Arthur
Finally I understood it, thans for the video ๐
To my relief this shouldn’t be too hard to implement.
Essentially, what is happening is that when the form is dynamically loaded on the page (with ajax), contact form 7 doesn’t know its there, and didn’t run its javascript to handle the interactions.
What you will need to do is add some javascript to your theme, to detect when our Ajax finishes, and to re-initialise the contact forms. Fortunately we have some events for that, and looking at the CF7 docs they have some to re-init their javascript.
Combining these would look like:
(function ( $ ) { "use strict"; function initContactForms() { $( 'div.wpcf7 > form' ).each( function() { var $form = $( this ); wpcf7.initForm( $form ); if ( wpcf7.cached ) { wpcf7.refill( $form ); } } ); } $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("S&F JS Ajax Request complete, re-init contact forms"); initContactForms(); }); }(jQuery));
Let me know how you get on ๐
-
AuthorPosts