From 2b3ff66006c4a1bf21ceca212768f5ce6dd1342e Mon Sep 17 00:00:00 2001 From: Caleb Cox Date: Thu, 18 Apr 2024 09:59:10 -0500 Subject: [PATCH] Add cf: events --- public/campaign-form.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/campaign-form.js b/public/campaign-form.js index 2fed9dd..08022e8 100644 --- a/public/campaign-form.js +++ b/public/campaign-form.js @@ -55,6 +55,11 @@ const postScriptLoad = function () { window.campaignForm.successCallback(data.master_person_id) } campaignForms[formId].submittedCallback?.(form) + form[0].dispatchEvent(new CustomEvent('cf:form-submitted', { + detail: { + formData: form.formData() + } + })) // redirect if setup if (typeof data.redirect_url !== 'undefined') { @@ -180,6 +185,12 @@ const postScriptLoad = function () { }) }) + document.dispatchEvent(new CustomEvent('cf:loaded', { + detail: { + formData: campaignForms + } + })) + toggleSubmitButtons(false); })(jQuery) }