I am running into what I believe is a race condition issue using a webflow form and am curious if anyone has had any luck doing something similar.
The order of operations I am aiming for is:
- User inputs form data, including postal code, city, province (I’m in Canada!)
- Upon submit the form calls on
.preventDefault()
and then runs the Google geo function to populate lat/long - Lat/long is mapped to two hidden form fields
-
Return true;
is run and the form submits as usual but now including the lat/long
Unfortunately it isn’t happening this way. If I halt the form all together with return false
I can see that geo is indeed running and populating the lat/long which is why I believe its a race condition issue. Anyone have success doing something like this with webflow forms?
Code I am using to pause form is based off the suggestions here: Disabling Form Submission? - #13 by kanji
My code including geo()
Webflow.push(function() {
$('#map-form').submit(function() {
e.preventDefault();
geo();
return true;
});
});
Here is my site Read-Only: https://preview.webflow.com/preview/future-us?utm_medium=preview_link&utm_source=designer&utm_content=future-us&preview=53ea1fe338effc74771360d9af5fe4c8&pageId=6234c2bd06fd03397b581910&workflow=preview