I find it difficult to sync blur and clicks. The scenario is as follows: I have a page in which I have a text box and a button. Now I have a blur event handler for the text field, which basically makes an AJAX request and refreshes part of the page. In addition, I have a click handler for a button that does other work.
Now the problem is that since I have a blur event handler in the text box, when I enter something into the text box and immediately click the button, it launches both blur and clicks (as expected). The problem is synchronizing the two, because the click handler should only be executed after the blur handler returns (if there was any blur event).
Sample code is as follows:
$('#textbox').on('blur', function(){
source share