How to use?
esFormsAfterCaptchaInit
Section titled “esFormsAfterCaptchaInit”In this example the event is hooked to the window object and in event details you have:
esForms- object.formId- not available because this is a global event.additional- object from the API response.
window.addEventListener('esFormsAfterCaptchaInit', ({detail}) => { const { additional, } = detail;
if (additional?.status === 'success') { const score = additional?.response?.score?.toString();
if (score) { // Do some actions with the score.
window.dataLayer.push({ event: 'recaptcha', recaptchaScore: score, }); } }});esFormsJsFormLoaded
Section titled “esFormsJsFormLoaded”In this example the event is hooked to the window element and in event details you have:
esForms- object.formId- form Id this event is a part of.
import domReady from '@wordpress/dom-ready';
domReady(() => { window.addEventListener('esFormsJsFormLoaded', ({detail}) => { const { formId, esForms, } = detail;
// Do some actions with the form. });});esFormsAfterFormSubmitReset
Section titled “esFormsAfterFormSubmitReset”In this example the event is hooked to the form element and in event details you have:
esForms- object.formId- form Id this event is a part of.additional- object from the API response.
const { store } = window.esForms.store;
[...document.querySelectorAll(store.getStateSelector('form'))].forEach((form) => { form.addEventListener('esFormsAfterFormSubmitReset', ({detail}) => { const { formId, esForms, additional } = detail; // Do some actions with the form. });});