代码之家  ›  专栏  ›  技术社区  ›  James Lin

jQuery UI选项卡,选择/取消选择(折叠)事件

  •  1
  • James Lin  · 技术社区  · 14 年前

    我正在使用jQuery UI 1.8.5tabs插件,具有可折叠的:真配置。

    2 回复  |  直到 12 年前
        1
  •  1
  •   Stephen    14 年前

    你可以检查一下 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 事件。

        2
  •  1
  •   James Khoury    13 年前

    那这个呢 show event

    甚至可能是 select event

    使用 '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
             }
        }
    });
    
    推荐文章