Deselecting a form input and waiting for a function before submitting
Posted
by blcArmadillo
on Stack Overflow
See other posts from Stack Overflow
or by blcArmadillo
Published on 2010-06-02T19:54:19Z
Indexed on
2010/06/02
20:04 UTC
Read the original article
Hit count: 338
I have a form with an input field where a user enters a unique identifier. I then have some jQuery code that upon the user moving away from the input field (blur) goes out and fetches details about the part and populates some fields on the page. The problem is if the user clicks the submit button before moving out of the input field the jQuery code never has a chance to load in the data and populate the necessary fields. Whats the best way to go about doing this? I thought about maybe setting the focus to body and then having an infinite loop that keeps checking the page until all fields that should be filled in have been filled in but I feel like some sort of event based solution would be better than unpredictable infinite loops. Any ideas?
© Stack Overflow or respective owner