jquery tabs 绑定(bind) tabsselect 或 tabsshow 未触发

标签 jquery jquery-ui event-handling

我在使用 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/

相关文章:

如果满足 <t​​d> 的某些值要求,则使用 jQuery 样式

php - 将 NULL 显示为无文本

javascript - JQuery 自动完成下拉菜单位置

C# 事件处理

javascript - 使用经典 ASP 上传

javascript - 这段 javascript 的结果是什么?

jquery - 为什么我的选择下拉列表之一会在内容加载到其下方后消失?

javascript - 如何避免将双空格算作单词?

event-handling - 如何根据 Julia 中的事件实现 ODE 解决方案的终止?为什么我会收到边界错误?

event-handling - Python 3 的事件循环实现?