akphidelt2007 Posted November 14, 2012 Share Posted November 14, 2012 Ok, so here is my little dilemma. I have a table that acts as a spreadsheet and allows the user to click a cell and pops open an input box. And when a blur event is triggered on the input box it runs some ajax to submit the data in to the database and then closes the input box and adds that value to the cell. My problem is, if I click really really fast on multiple cells, multiple input boxes pop up and the blur event is not triggered. Is there a way to handle this type of action. I know it's nitpicky, but I can just imagine some of our engineers clicking too fast and getting this little bug. Please let me know if there is anything I can do about this. Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/270693-trigger-onblur-event-even-with-very-fast-clicking/ Share on other sites More sharing options...
requinix Posted November 14, 2012 Share Posted November 14, 2012 Are you giving focus to the textboxes when they're created? If not then that would explain why onblur isn't firing: there was no focus to lose in the first place. Quote Link to comment https://forums.phpfreaks.com/topic/270693-trigger-onblur-event-even-with-very-fast-clicking/#findComment-1392433 Share on other sites More sharing options...
Drongo_III Posted November 15, 2012 Share Posted November 15, 2012 (edited) Ok, so here is my little dilemma. I have a table that acts as a spreadsheet and allows the user to click a cell and pops open an input box. And when a blur event is triggered on the input box it runs some ajax to submit the data in to the database and then closes the input box and adds that value to the cell. My problem is, if I click really really fast on multiple cells, multiple input boxes pop up and the blur event is not triggered. Is there a way to handle this type of action. I know it's nitpicky, but I can just imagine some of our engineers clicking too fast and getting this little bug. Please let me know if there is anything I can do about this. Thanks in advance! As there's no code I would suggest one of the following: Set a flag when an input box is opened. Then at the start of your click function do a check to see if that flag is true and if it is then don't continue running the click function. So this way you constrain the user to only having one input active at any one time. Then on blur you can reset the flag. Another option might be to set a timer so that the function cannot be run again until say 1-2 seconds has elapsed. Hope those suggestions help a bit! Edited November 15, 2012 by Drongo_III Quote Link to comment https://forums.phpfreaks.com/topic/270693-trigger-onblur-event-even-with-very-fast-clicking/#findComment-1392715 Share on other sites More sharing options...
akphidelt2007 Posted November 15, 2012 Author Share Posted November 15, 2012 Thanks for your replies. Drongo, I actually ended up with your advice by pure accident. When a user was clicking in to the text box it would create another text box, so I built that flag to make sure that an active box was already present and if it was then skip the code process. That ended up doing the trick. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/270693-trigger-onblur-event-even-with-very-fast-clicking/#findComment-1392725 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.