jQuery UI 选项卡嵌套选项卡事件触发和绑定
我正在使用嵌套的 jQuery UI 选项卡,如下所示 http://jsfiddle.net/VvFyM/1/
我试图分别绑定到 tabsselect 事件外部选项卡和嵌套的选项卡。问题是,每当触发嵌套选项卡的 tabsselect 事件时,似乎:
- 外部选项卡的 tabsselect 处理程序也捕获它,或者
- 外部选项卡的 select 事件也被触发 (因此它被捕获)。
是哪一个?
那么有没有办法分别触发和绑定这2个事件呢?
所以,
$("#tabs").bind("tabsselect", function(ev, ui){
console.log("Tab selected");
})
我不想做类似的
$("#tabs").bind("/*tabsselect outside tabs only*/", function(ev, ui){
console.log("Tab selected");
})
事情
$("#tabs").bind("/*tabsselect inside tabs only*/", function(ev, ui){
console.log("Tab selected");
})
I'm using nested jQuery UI tabs as shown here http://jsfiddle.net/VvFyM/1/
I'm trying to bind to the tabsselect event separately for both the outside tabs and the nested tabs. Problem is, whenever the nested tab's tabsselect event is triggered, it seems that either:
- The outside tab's tabsselect handler catches it as well, or
- The outside tab's select event is also triggered (hence it is caught).
Which is it?
Then, is there a way to trigger and bind the 2 events separately?
So, instead of
$("#tabs").bind("tabsselect", function(ev, ui){
console.log("Tab selected");
})
I want to do something like
$("#tabs").bind("/*tabsselect outside tabs only*/", function(ev, ui){
console.log("Tab selected");
})
and
$("#tabs").bind("/*tabsselect inside tabs only*/", function(ev, ui){
console.log("Tab selected");
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要在初始化后绑定选择函数,而是在初始化选项卡时绑定它,这解决了问题。我更新了你的小提琴以显示这一点: http://jsfiddle.net/R5sSh/
Instead of binding the select function after initialization bind it while you initialize the tabs and that solves the problem. I updated your fiddle to show this: http://jsfiddle.net/R5sSh/
此外,您可以删除
ui-tabs-selected
和ui-tabs-active
类,然后可以使用$('#tabscontainer').tabs( “选择”,hashOrIndex);
Additionally, you can remove the
ui-tabs-selected
andui-tabs-active
classes, then you can use$('#tabscontainer').tabs( "select", hashOrIndex );