CMS Development

Siyabonga
Mitglied

Embedded form function

lösung

Is there a way to ensure that my method inside onFormSubmit has fully run before the forms redirect happens?

0 Upvotes
1 Akzeptierte Lösung
lscanlan
Lösung
HubSpot-Alumnus/Alumna
HubSpot-Alumnus/Alumna

Embedded form function

lösung

Hi @Siyabonga,

 

So far as I know, that's not possible. I believe the form redirect creates a new thread in the browser, which the callback functions don't have access to. There is some time before the redirect happens, so if you're running code that only takes a few milliseconds, the code should run I'd think. But if you're trying to do something that takes more time, like with timeouts or with promises, you could consider adding the redirect into your callback function. And then within the form editor, just select the inline thank you message option instead of the redirect.

 

You've probably seen our docs, but we have those callbacks and events documented here: https://developers.hubspot.com/docs/methods/forms/advanced_form_options and here: https://developers.hubspot.com/global-form-events.

 

If you're having trouble with a specific page, feel free to let me know and link it here.

 

Thanks,

Leland

Leland Scanlan

HubSpot Developer Support

Lösung in ursprünglichem Beitrag anzeigen

0 Upvotes
1 Antwort
lscanlan
Lösung
HubSpot-Alumnus/Alumna
HubSpot-Alumnus/Alumna

Embedded form function

lösung

Hi @Siyabonga,

 

So far as I know, that's not possible. I believe the form redirect creates a new thread in the browser, which the callback functions don't have access to. There is some time before the redirect happens, so if you're running code that only takes a few milliseconds, the code should run I'd think. But if you're trying to do something that takes more time, like with timeouts or with promises, you could consider adding the redirect into your callback function. And then within the form editor, just select the inline thank you message option instead of the redirect.

 

You've probably seen our docs, but we have those callbacks and events documented here: https://developers.hubspot.com/docs/methods/forms/advanced_form_options and here: https://developers.hubspot.com/global-form-events.

 

If you're having trouble with a specific page, feel free to let me know and link it here.

 

Thanks,

Leland

Leland Scanlan

HubSpot Developer Support
0 Upvotes