Opened 13 years ago
Closed 13 years ago
#7009 closed bug (duplicate)
Inline events are not being canceled by using "return false"
Reported by: | Alien003 | Owned by: | |
---|---|---|---|
Priority: | Milestone: | 1.4.3 | |
Component: | event | Version: | 1.4.2 |
Keywords: | return false PropagationStopped DefaultPrevented | Cc: | |
Blocked by: | Blocking: |
Description
If in a page there is a event (like onclick) and it ends with a "return false;", if the event is triggered with .click() it still propagates and does the default behavior instead of being canceled.
Its not even the same behavior as clicking the button with the mouse.
I see that the result of those events is being stored in event.result ... so here is my tentative fix:
jQuery.Event.prototype.effectiveResult = function() {
return this.result !== undefined ? !this.result : false;
}
jQuery.Event.prototype.isDefaultPrevented = jQuery.Event.prototype.effectiveResult; jQuery.Event.prototype.isPropagationStopped = jQuery.Event.prototype.effectiveResult; jQuery.Event.prototype.isImmediatePropagationStopped = jQuery.Event.prototype.effectiveResult;
Dup of #6337; try the patch shown there and see if it fixes things as you expected. If not, reopen this ticket.