Skip to main content

Bug Tracker

Side navigation

#7217 closed bug (fixed)

Opened October 16, 2010 08:43PM UTC

Closed October 25, 2010 08:05PM UTC

Last modified March 19, 2012 09:19PM UTC

.live and .delegate, multiple handlers

Reported by: b.w@xs4all.nl 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

Attachments (0)
Change History (8)

Changed October 16, 2010 09:30PM UTC by anonymous comment:1

Changed October 17, 2010 12:12AM UTC by snover comment:2

component: unfiledevent
keywords: → needsreview

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.

Changed October 22, 2010 12:31AM UTC by snover comment:3

resolution: → invalid
status: newclosed

The behavior in 1.4.2 is wrong. 1.4.3 behaves correctly here.

Changed October 22, 2010 01:37PM UTC by b.w@xs4all.nl comment:4

OK, thanks, so how do I get the desired behaviour, which is to prevent the second handler from being called?

Changed October 23, 2010 04:38PM UTC by dmethvin comment:5

keywords: needsreview
priority: undecidedlow
resolution: invalid
status: closedreopened

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.

Changed October 23, 2010 06:43PM UTC by dmethvin comment:6

Changed October 23, 2010 06:54PM UTC by dmethvin comment:7

owner: → dmethvin
status: reopenedassigned

Changed October 25, 2010 08:05PM UTC by dmethvin comment:8

resolution: → fixed
status: assignedclosed

Honor stopImmediatePropagation for live/delegate event handlers. Fixes #7217.

Changeset: 974b5aeab7a3788ff5fb9db87b9567784e0249fc