Opened 6 years ago

Closed 6 years ago

#9220 closed bug (notabug)

Incorrect click event propagation for button when based off checkbox

Reported by: brycenz Owned by:
Priority: minor Milestone: none
Component: ui.button Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:

Description

If you have a jQuery UI button widget created off a button everything seems to work right, in the click event handler event.stopPropagation() will prevent the event from going up to higher elements in the DOM.

However if you create a button widget from a checkbox then the click event will first fire against each of the elements up the DOM tree, then fire the button click handler, then fire again up the tree.

The second set of propagation up the tree will be stopped by event.stopPropagation() in the button click event, but the first set will not be stopped. If you try to be "smart" and stop the propagation at say a wrapper that is around your button then it works.

However if you have an event.preventDefault() at any point higher in the DOM (and haven't stopped the propagation at say a wrapper element, then the button click event handler will not fire.

I am assuming that this is a bug, but if not then it needs to be clearly stated that this behaviour is what happens somewhere in the documentation.

Change History (2)

comment:1 Changed 6 years ago by brycenz

I meant to add this link as an example: http://jsbin.com/ofijaf/2/edit

comment:2 Changed 6 years ago by Scott González

Resolution: notabug
Status: newclosed

This is not a bug, this is what happens when you click on a label. The click of the label bubbles up, then the checkbox is clicked as a result. Try it for yourself without jQuery UI: http://jsbin.com/ofijaf/3/edit

Note: See TracTickets for help on using tickets.