Bug Tracker

Ticket #7217 (closed bug: fixed)

Opened 5 years ago

Last modified 3 years ago

.live and .delegate, multiple handlers

Reported by: b.w@… Owned by: dmethvin
Priority: low Milestone: 1.4.4
Component: event Version: 1.4.3
Keywords: Cc:
Blocking: Blocked by:


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

comment:2 Changed 5 years ago by snover

  • Keywords needsreview added
  • Component changed from unfiled to event

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 5 years ago by snover

  • Status changed from new to closed
  • Resolution set to invalid

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

comment:4 Changed 5 years ago by b.w@…

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

comment:5 Changed 5 years ago by dmethvin

  • Keywords needsreview removed
  • Priority changed from undecided to low
  • Status changed from closed to reopened
  • Resolution invalid deleted

OK, based on the test case here:


Looks like we need an isImmediatePropagationStopped in liveHandler. I'll put together a patch.

comment:7 Changed 5 years ago by dmethvin

  • Owner set to dmethvin
  • Status changed from reopened to assigned

comment:8 Changed 5 years ago by dmethvin

  • Status changed from assigned to closed
  • Resolution set to fixed

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

Changeset: 974b5aeab7a3788ff5fb9db87b9567784e0249fc

Note: See TracTickets for help on using tickets.