jQuery UI选项卡,选择/取消选择(倒塌)事件
题
我使用的是JQuery UI 1.8.5选项卡插件,带有Coldapsible:True Configuration。在折叠选项卡以添加CSS类后,我需要调用功能。有人知道如何吗?
解决方案
您可以检查是否 ui-tabs-selected
单击时存在类。假设您正在使用标准标记:
// in your click event
var selected_exists = $('#yourTabBox')
.children('ul.ui-tabs-nav')
.children('li.ui-tabs-selected')
.length;
if (selected_exists) {
// Nothing is collapsed
} else {
// collapsed
}
这是完美的 select
事件。
其他提示
怎么样 展示活动 为此不起作用吗?因为您不知道哪一个被隐藏了?
甚至可能 选择事件 可能是你想要的。
使用 'tabsselect' 事件:
$(".selector").tabs({
collapsible: true,
select: function(event, ui)
{
var prevSelectedIndex = $(".selector").tabs('option', 'selected');
var nextSelectedIndex = ui.index;
if(prevSelectedIndex === -1)
{
// It was previously collapsed and the user is now opening
// tab at index: nextSelectedIndex
}
else if(prevSelectedIndex === nextSelectedIndex )
{
// The user has clicked on the currently opened
// tab and it is collapsing
}
}
});
不隶属于 StackOverflow