#1948 closed bug (invalid)
handle(): Stop event bubbling for other jQuery handlers?
Reported by: | olau | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.2.2 |
Component: | event | Version: | 1.2.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Shouldn't "return false;" in an event handler prevent other jQuery handlers from running? That's how I understand the docs.
Currently, code like this
$(".ensureLoggedIn").click(function (event) {
console.log("test1"); return false;
}).click(function() {
console.log("test2");
});
prints "test1" followed by "test2". Which is not surprising given that handle() in jQuery calls preventDefault and stopPropagation but doesn't stop the handler invocation loop. If you add "break;" after the call to stopPropagation in handle(), I only get "test1" and not "test2".
Change History (4)
comment:1 Changed 15 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:3 Changed 15 years ago by
FWIW, I've clarified the docs a bit (http://docs.jquery.com/Events_%28Guide%29 and http://docs.jquery.com/Events/bind) for those of us who don't know the standards as well as others. :-)
comment:4 Changed 12 years ago by
This write up helped me, thank you for taking the time to post a resolution to the problem.
It stops the event from bubbling to a parent. It does not prevent other handlers from running on the same element. This is in accordance with the standards. It should also be noted that there is no guarantee to the order in which the handlers are invoked.