Skip to main content

Bug Tracker

Side navigation

#5378 closed bug (invalid)

Opened October 14, 2009 09:32PM UTC

Closed October 15, 2009 12:28AM UTC

click event of a parent triggered when clicking children

Reported by: the_hero Owned by: brandon
Priority: major Milestone: 1.4
Component: event Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:
Description

Parent element click events are triggered on children elements,

When you assign a click event to a parent element there is currently no way to stop this event from triggering when clicking a child of this parent.

In some situations this is necessary. It is nice to be able to just assign the event to the parent and not worry that it won't be triggered when clicking anywhere inside it including the children. However, much of the time people will have a parent element that does something other than than the parent, sometimes opposite.

Try the attached code to test.

Attachments (1)
  • test_events.html (1.1 KB) - added by the_hero October 14, 2009 09:33PM UTC.

    Test this code to see this occurring

Change History (2)

Changed October 14, 2009 09:52PM UTC by the_hero comment:1

Unbind on the children does not block the parent event from being triggered.

Changed October 15, 2009 12:28AM UTC by dmethvin comment:2

resolution: → invalid
status: newclosed

Click events bubble all the way up to the document, since the parent elements contain the child that was clicked. If you don't want the parent element(s) to act on the click, have their event handler check for event.target==this and return if it is not.