Bug Tracker

Ticket #2610 (closed bug: invalid)

Opened 10 months ago

Last modified 10 months ago

"return false" doesn't work

Reported by: telega Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.2.4 Component: event
Version: 1.2.3 Keywords:
Cc: Needs: Review

Description

I have 2 onclick handlers assigned to a document, each one returning false. But clicking on the document causes both handlers to be invoked disregarding "return false". Happens in all the browsers (FF 3, Opera 9, IE 7). Tried "click" and "mousedown" events, both have the same behavior.

<script src="jquery-1.2.3.js"></script>
<script>
  $(document).ready(function() {
    $(document).bind("click", "data1", function() { alert('click1'); return false; });
    $(document).bind("click", "data2", function() { alert('click2'); return false; });
  });
</script>

Attachments

Change History

Changed 10 months ago by scott.gonzal

  • status changed from new to closed
  • resolution set to invalid

Straight from the docs:

To stop both default action and event bubbling, your handler has to return false. Note that this will prevent handlers on parent elements from running but not other jQuery handlers on the same element.

Note: See TracTickets for help on using tickets.