APIs & Integrations

TuHoang
Participant

Form submission callback object type

Hello,

 

For now, the callback object of Form submission is a jQuery object. Could we get it as a native JS object? Because we dont use jQuery on our webpages.

 

Thanks,

Tu

3 Replies 3
lscanlan
HubSpot Alumni
HubSpot Alumni

Form submission callback object type

Hi Tu,

 

Take a look at this thread here: https://community.hubspot.com/t5/Share-Your-Work/Global-Form-Event-Listener-for-HubSpot-Forms-JavaSc....

 

It should be possible to instead just listen for the form submission event. So similar to how they're listening for the form ready event in that thread like so:

 

window.addEventListener('message', event => {
   if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') {
       // the form is ready to manipulate!
   }
});

 

...you should also be able to listen for the form submit event like so:

 

window.addEventListener('message', event => {
   if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') {
       // form submit callback
   }
});

Want to give that a try and let me know if that helps?

 

 - Leland

Leland Scanlan

HubSpot Developer Support
TuHoang
Participant

Form submission callback object type

I will try that approach.

 

Thanks Leland.

 

 

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Form submission callback object type

Hey @TuHoang,

 

I went ahead and created a post in the Ideas Forum for this; feel free to jump over and give it kudos, and share in your network!

 

https://community.hubspot.com/t5/HubSpot-Ideas/Form-embed-code-should-return-a-vanilla-JavaScript-ob...