Reputation: 28743
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?
Upvotes: 3
Views: 5539
Reputation: 207881
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] );
Upvotes: 2