我在使用 jquery 选项卡时遇到问题。如果我绑定(bind)到选项卡的 tabsselect 或 tabsshow 事件,它们不会被触发。
我正在使用最新的 jquery-ui 1.10.3,并且我的 web 应用程序控制台中没有 js 错误。
代码:
$("#tabs").tabs();
$("#tabs").bind('tabsselect', function(event, ui) {
alert(ui.index); // This is never displayed
if (ui.index === 1 && plot1._drawCount === 0) {
plot1.replot();
}
else if (ui.index === 2 && plot2._drawCount === 0) {
plot2.replot();
}
});
最佳答案
事件是activate
$("#tabs").on('tabsactivate', function(event, ui) {
var index = ui.newTab.index();
alert(index); // This is never displayed
if (ui.index === 1 && plot1._drawCount === 0) {
plot1.replot();
}
else if (ui.index === 2 && plot2._drawCount === 0) {
plot2.replot();
}
});
演示:Fiddle
关于jquery tabs 绑定(bind) tabsselect 或 tabsshow 未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18769208/