Bug Tracker

Opened 12 years ago

Closed 12 years ago

#7353 closed bug (invalid)

Subsequent live event handlers can't be cancelled by returning false

Reported by: ashrewdmint Owned by:
Priority: undecided Milestone: 1.5
Component: unfiled Version: 1.4.3
Keywords: Cc:
Blocked by: Blocking:


Documentation for live events says the following:

"To stop further handlers from executing after one bound using .live(), the handler must return false. Calling .stopPropagation() will not accomplish this."

However, this does not seem to be the case. If you put the following HTML in a browser and click the link, the second live event is not blocked.

Maybe I am misreading the documentation?

<!DOCTYPE html>
		<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
		<script type="text/javascript">
			$('a').live('click', function(){
			  alert('hello, this is the first live event');
			  return false;
			$('a').live('click', function(){
			  alert('this should not show up');
		<a href="#">Click me</a>

Change History (3)

comment:1 Changed 12 years ago by ashrewdmint

My bad, I didn't see the notice about jsFiddle before.

Here's my example on jsFiddle - http://jsfiddle.net/6krK5/

comment:3 Changed 12 years ago by jitter


You should use stopImmediatePropagation() for this not return false. The behavior in 1.4.2 was wrong that's why returning false worked but didn't anymore in 1.4.3.

Unfortunately calling stopImmediatePropagation() doesn't work in 1.4.3 for live handlers, but this has already been fixed and will work once 1.4.4 comes out.

Check also the comments on #7217 for more info on this.

Your test case with jQuery dev version

comment:4 Changed 12 years ago by Rick Waldron

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.