Javascript event not firing

By: Liudas Dzisevicius | Asked: 12/01/2023
ForumsCategory: Code HelpJavascript event not firing
Liudas Dzisevicius asked 1 year ago

Hello I'm trying do something in JS after form has been submitted but following the documentation isn't working for me. I've created a from and set it to be submitted using AJAX. I've added it to a page using the shortcode and using the custom html block I've added this code:

(() => {
document.addEventListener('frmFormComplete', (event, form, response) => {
console.log('test');
});
})();

After the form is submitted I don't see anything in the console. Am I doing something wrong or this is a bug? The doc page I'm following: https://formidableforms.com/knowledgebase/javascript-examples/javascript-after-form-submit/#kb-perform-action-after-form-submit

3 Answers
Best Answer
Liudas Dzisevicius answered 1 year ago
It seems vanilla JS can't catch events triggered by Jquery. Thank you for your help guys.
Rob LeVineRob LeVine answered 1 year ago
I set up a quick test, first using the format in the example on the FF documentation page and it worked. I then substituted your code and it did not.
Victor Font answered 1 year ago
It works the Formidsable adds the listener: jQuery( document ).on( 'frmFormComplete', afterFormSubmitted );

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right