Noobie alert: Native form's onSubmit event handler or hook?
Hi guys, this is my first stab at any HS development. We’re integrating with SalesForce, but due to how we’ve frankensteined SalesForce we can’t sync, I promise I’ve researched the heck out of this, even selective sync can’t help, we’re making SalesForce do way too much and done too much data mangling.
Our implementer has created a native contact form for us which is great. First name, last name, email, city/state/zip, comments.
When the submit button is hit, in addition to submitting to HubSpot, we’d also like to hook our own code which will allow us to talk with our own API (which talks to our SalesForce).
Questions
Is there an “onSubmit” or “postSubmit” event handler that I can hook my own code on to?
Does is sound like I’m thinking about this the right way?
Noobie alert: Native form's onSubmit event handler or hook?
@caseywise phema109 is right. Use that page, specifically onFormSubmit. If you need to handle the form submission elsewhere, you might be able to use jQuery to trigger the event you can read in from your own API integration. Something like $form.trigger('hubspot:form:submit') and then use jquery’s bind() to listen for that event and parse the data from the hubspot form in javascript. This is assuming you are using AJAX forms.
Noobie alert: Native form's onSubmit event handler or hook?
@pmanca, massively appreciate your input. I feel like I’m getting less dumber w/ HubSpot development, problem is more dumb still apparently needs shaken loose.