Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jquery blur event firing on entry

Status
Not open for further replies.

tshad

Programmer
Jul 15, 2004
386
US
I have an issue where my blur event is firing on exit of one textbox and entry of another.

The two text boxes are next to each other and when I enter the first textbox, it does not fire (as it shouldn't). Then I exit the textbox by either tabbing or mousing to the 2nd text box. The event for the first textbox fires and when I leave that event, the event for the 2nd text box fires as I enter it.

Why is that?

It is only supposed to fire when you lose focus not when you gain focus.

Thanks,

Tom
 
I found out what is happening but not why.

Running in visual studio, I have a break point inside the event. The same event is hooked up for both textboxes.

If I put a return as the first statement so that nothing else happens, I actually get the event firing 3 times (should only happen once as I leave the textbox).

If I put the mouse on something else on the page (empty area or tab) where a blur event is not hooked up, it only fires once.

If you turn off debugging (no breakpoints in the event), it only fires once.

For some reason, going to the 2nd box causes the blur event to fire. I assume it is losing focus for some reason as the breakpoint is hit and then gets focus again.

Why is this happening?

Thanks,

Tom
 
Because going to a breakpoint means the object loses focus.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
That was what I figured.

It also means you can't really trace the code if it goes into a object that has an blur event on it.

Thanks,

Tom
 
Thinking about this again.

Actually, the issue is that the debugging must not be working correctly.

If the event is on the blur event of the 2nd textbox, then the blur event should not be firing. Hence, the breakpoint should not be hit until I leave the 2nd textbox.

Thanks,

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top