jQuery UI 切换按钮事件
如何将事件绑定到 jQuery UI 切换按钮?更具体地说,如何绑定将要触发的事件?
复选框正在渲染以正确切换按钮,但当按钮状态更改时,不会触发附加到它们的任何事件处理程序。我有什么遗漏的吗?
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设 jQuery-UI 切换按钮没有什么特别奇怪的:
文档,来自 http://api.jquery.com/< /a>,在
live
事件处理程序上。代替'click
有关完整详细信息,请参阅 http://api.jquery.com/live/ 参考。
正如@Peter Ajtai 指出的(在评论中):
(强调我的)
Assuming that there's nothing particularly odd about the jQuery-UI toggle buttons:
Documentation, from http://api.jquery.com/, on the
live
event-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)