I have two text boxes, both have blur events handled through jQuery. When a text box is blurred, some validation occurs and if the validation fails the text box is refocused (an awful idea, i know, but it's desired behavior in this case).
In chrome, if you focus the first text box then try to focus the second, you'll see this order of events happen:
- focus fired from text1
- blur fired from text1
- focus fired from text1
In IE8, however, you'll see this:
- LOG: focus fired from text1
- LOG: blur fired from text1
- LOG: focus fired from text1
- LOG: focus fired from text2
- LOG: blur fired from text2
- LOG: focus fired from text1
I need to be able to prevent the focus and blur events from firing on the second text box in the case that the first text box is being refocused.
Here is a fiddle demonstrating the issue. The behavior only happens in IE8.
Some more information: all of these event handlers are bound in separate private scopes, so the two text boxes have no way (that I know of) of interacting with each other's handler functions.
blur1 focus1 focus2
but 1 doesn't get focus back (FF17). – Fabrício MattésetTimeout(function() { $('#text1').focus(); }, 0);
is ugly and will fire the 2nd textbox's events but takes care of it as well. – Fabrício Matté