Side navigation
#7353 closed bug (invalid)
Opened October 29, 2010 08:21PM UTC
Closed October 29, 2010 09:41PM UTC
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: |
Description
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> <html> <head> <title>Hello</title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('a').live('click', function(){ alert('hello, this is the first live event'); return false; }); $('a').live('click', function(){ alert('this should not show up'); }); }); </script> </head> <body> <a href="#">Click me</a> </body> </html>
Attachments (0)
Change History (3)
Changed October 29, 2010 08:27PM UTC by comment:1
Changed October 29, 2010 09:30PM UTC by comment:2
@ashrewdmint
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
Changed October 29, 2010 09:41PM UTC by comment:3
resolution: | → invalid |
---|---|
status: | new → closed |
My bad, I didn't see the notice about jsFiddle before.
Here's my example on jsFiddle - http://jsfiddle.net/6krK5/