2012-03-28 290 views
0

我的UI選項卡可以根據用戶操作進行更改(例如 - 狀態消息可能出現在選項卡[0]中)。Jquery UI禁用動態選項卡

我也需要能夠禁用特定的選項卡 - 我知道href,但索引可能會改變。

UI dox表示你可以傳遞一個href而不是索引,但我似乎無法得到這個飛行。

這是我在做什麼,而不是:

var disableSlots = []; 
$('ul.ui-tabs-nav li').each(function(index, el){ 
    if ($(this).children('a').attr('href') == '#DISABLE_ME'){ 
     disableSlots.push(index); 
    } 
}); 
$('#tabs').tabs("option","disabled",disableSlots); 

有沒有更好的辦法?

回答

0

你可以使用這種方法:

var index = $('#tabs a[href="#DISABLE_ME"]').parent().index(); 
$('#tabs').tabs("option", "disabled", index);