简体   繁体   English

jQuery UI禁用动态选项卡

[英]Jquery UI disable dynamic tabs

My UI tabs can change based on user action (example - a status message may appear in tab[0]). 我的UI选项卡可以根据用户操作进行更改(例如-选项卡[0]中可能显示状态消息)。

I also need to be able to disable specific tabs - I know the href, but the index may well change. 我还需要能够禁用特定的选项卡-我知道href,但是索引可能会发生变化。

The UI dox say that you can pass a href instead of an index, but I can't seem to get that to fly. UI dox表示您可以传递href而不是索引,但是我似乎无法实现。

This is what I am doing instead: 这是我正在做的:

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);

Is there a better way? 有没有更好的办法?

You could use this approach: 您可以使用这种方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM