Search and Top Navigation
#9220 closed bug (notabug)
Opened April 10, 2013 10:13AM UTC
Closed April 10, 2013 11:41AM UTC
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.
Attachments (0)
Change History (2)
Changed April 10, 2013 10:15AM UTC by comment:1
Changed April 10, 2013 11:41AM UTC by comment:2
resolution: | → notabug |
---|---|
status: | new → closed |
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
I meant to add this link as an example:
http://jsbin.com/ofijaf/2/edit