如何取消手风琴控件的更改事件
$("#accordion").accordion({
change: function (event, ui) {
alert('event have to be changed')
},
changestart: function (event, ui) {
return false;
}
});
是否可以取消更改事件?
$("#accordion").accordion({
change: function (event, ui) {
alert('event have to be changed')
},
changestart: function (event, ui) {
return false;
}
});
Is it possible to cancel the change event?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我不确定更改,但对于 jqueryui 中的其他事件返回 false 会取消该事件。
I am not sure about change but for other events in jqueryui returning false cancels the event.
stopPropagation() 是停止处理 jQueryUI 操作的关键,但它必须在changestart 事件之前中断。例如,当实际单击标题项时。
如果这是手风琴中的标题/内容对:
那么这将阻止手风琴在单击标题时展开 div:
请参阅 jquery Accordion 防止冒泡/允许默认链接操作。
stopPropagation() is the key to stopping a jQueryUI action from processing, but it must be interrupted BEFORE the changestart event. For example, when the header item is actually clicked.
If this is a header/content pair in your accordion:
Then this will prevent the accordion from expanding the div when the header is clicked:
See jquery accordion prevent bubbling / allow default link action.
正如马丁所说,你可以返回 false。请参阅下面的代码示例。
As Martin said you can return false. See a code sample below.
返回 false 不会执行任何操作,要取消 jQueryUI 中的事件,您需要对该事件调用 PreventDefault()。
这应该适用于所有事件方法,包括自动完成。如果您希望在自动完成菜单中包含一些自定义选项,您希望有人选择这些选项,但实际上不想添加到与其关联的输入中,那么这会很方便。 :)
Returning false does nothing, to cancel an event in jQueryUI you need to call preventDefault() on the event.
This should work with all event methods, including autocomplete. Handy if you wish to include a few custom options in your autocomplete menu that you want someone to select but don't actually want to add to the input it is tied to. :)
对我有用的是调用:
在函数末尾返回
false
具有相同的效果,因为它相当于进行这两个函数调用。What worked for me is calling:
Returning
false
at the end of the function has the same affect because it's the equivalent of making those two function calls.