How do I bind events to a jQuery UI Toggle button? More specifically, how can I bind events that are going to fire?
The checkboxes are rendering to toggle buttons correctly, but any event handlers attached to them are not triggered when the state of the button changes. Is there something I’m missing?
CSS:
<input type='checkbox' id='recording'/> <label for='recording'> Recording </label>
JavaScript:
$('#recording').button() // works
.click(fn) // doesnt work
.changed(fn) // doesnt work
.toggle(fn, fn2) // doesn't work
Assuming that there’s nothing particularly odd about the jQuery-UI toggle buttons:
Documentation, from http://api.jquery.com/, on the
liveevent-handler.In place of ‘click’ you can also use:
See the http://api.jquery.com/live/ reference for full details.
As @Peter Ajtai noted (in comments):
(Emphasis mine)