This commit removes the global jQuery selectors from the script. These selectors would pick up on every toggle button that existed, meaning that having multiple toggle buttons on the same page had the possibility of binding the onChange callback to it's toggle button multiple times.
This change also negates the need for e.preventDefault() and e.stopImmediatePropagation(), which allows for outside scripts to bind on the hidden checkbox's change event without affecting the functionality of the toggle buttons.
This commit removes the global jQuery selectors from the script. These selectors would pick up on every toggle button that existed, meaning that having multiple toggle buttons on the same page had the possibility of binding the onChange callback to it's toggle button multiple times.
This change also negates the need for
e.preventDefault()
ande.stopImmediatePropagation()
, which allows for outside scripts to bind on the hidden checkbox'schange
event without affecting the functionality of the toggle buttons.