Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery tabs: disable first tab, select second

I'm using jQuery tabs to create a tab bar with four tabs. After the tabs are initialized, when a certain link is clicked, I want to disable the first tab and select the second tab.

I can successfully disable the second tab and select the first like this (inside my click function):

$("#settings-tabs").tabs("option", {
    "disabled": [0, 1],
    "selected": 0
});

But how do I disable the first tab and select the second? Well, selecting the second tab is easy: "selected": 1. But I can't figure out how to disable the first tab. I've tried:

"disabled": [0, 0]
"disabled": [0]
"disabled": 0
"disabled": [-1, 0]

In all cases, the second tab will be selected by default, but then I can still click on the first tab to switch back to it.

What am I missing?

like image 287
daGUY Avatar asked May 16 '26 07:05

daGUY


1 Answers

Try calling select prior to calling diabled: jsFiddle example

$("#tabs").tabs();
$("#tabs").tabs("option", {
    "selected": 1,
    "disabled": [0]
});​

or

$("#tabs").tabs();
$( "#tabs" ).tabs( "option", "selected", 1 );
$( "#tabs" ).tabs( "option", "disabled", [0] );​
like image 85
j08691 Avatar answered May 19 '26 03:05

j08691



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!