#7217 closed bug (fixed)
.live and .delegate, multiple handlers
Reported by: | Owned by: | dmethvin | |
---|---|---|---|
Priority: | low | Milestone: | 1.4.4 |
Component: | event | Version: | 1.4.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Given the code at http://jsfiddle.net/NxjMy/, on clicking 'click me', using jQuery 1.4.2, I get an alert 'foo' and nothing else, but with 1.4.3, I get two consecutive alerts: 'foo' and 'bar'.
This behaviour happens at least with recent versions of Firefox, Google Chrome and Opera. A similar thing happens with .live().
I could not find information about this change in the 1.4.3 release notes. What is going on?
Thanks, Bart
Change History (8)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → event |
---|---|
Keywords: | needsreview added |
So I am pretty sure the behaviour in 1.4.2 was wrong; return false
does not call stopImmediatePropagation
and so should not prevent subsequent handlers on the same element from executing. On the other hand, manually calling stopImmediatePropagation
does not work to stop subsequent handlers in 1.4.3. So, I’m going to mark this for further review.
comment:3 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
The behavior in 1.4.2 is wrong. 1.4.3 behaves correctly here.
comment:4 Changed 12 years ago by
OK, thanks, so how do I get the desired behaviour, which is to prevent the second handler from being called?
comment:5 Changed 12 years ago by
Keywords: | needsreview removed |
---|---|
Priority: | undecided → low |
Resolution: | invalid |
Status: | closed → reopened |
OK, based on the test case here:
http://forum.jquery.com/topic/e-stopimmedidatepropagation-does-not-work-with-live-or-with-delegate
Looks like we need an isImmediatePropagationStopped in liveHandler. I'll put together a patch.
comment:6 Changed 12 years ago by
comment:7 Changed 12 years ago by
Owner: | set to dmethvin |
---|---|
Status: | reopened → assigned |
comment:8 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Honor stopImmediatePropagation for live/delegate event handlers. Fixes #7217.
Changeset: 974b5aeab7a3788ff5fb9db87b9567784e0249fc
Maybe it's because of this commit? http://github.com/jquery/jquery/commit/31432e048f879b93ffa44c39d6f5989ab2620bd8