我正在将代码从jQuery UI 1.8升级到1.10。
在1.8下,标签更改时触发的事件为select
,我可以通过ui.index
访问正在选中的标签的索引。
在1.10下,选项卡更改时触发的事件为activate
。但是,我在事件参数ui
中找不到任何告诉我新激活的选项卡索引的内容。
我如何发现该索引?
答案 0 :(得分:22)
您可以使用以下方法http://jsfiddle.net/9ChL5/1/:
$("#tabs").tabs({
activate: function (event, ui) {
console.log(ui.newTab.index());
}
});
答案 1 :(得分:0)
UI对象仍然存在,但似乎直接包含oldTab,newTab,oldPanel,newPanel的jQuery对象,因此您不需要索引来查找要使用的对象。
请参阅http://api.jqueryui.com/tabs/#event-activate
ui Type: Object
- newTab
Type: jQuery
The tab that was just activated.
- oldTab
Type: jQuery
The tab that was just deactivated.
- newPanel
Type: jQuery
The panel that was just activated.
- oldPanel
Type: jQuery
The panel that was just deactivated.