views:

42

answers:

2

Hi, I can't find in the API of jQuery UI Tabs ( http://docs.jquery.com/UI/Tabs) a method to know if a certain tab is enabled or not, I want that because in an event of my application I want to enable a certain tab only if that tab is disabled..

Thanks in advance.

A: 

You're almost there (it's on your link): disabled

//getter
var disabled = $( ".selector" ).tabs( "option", "disabled" );
//setter
$( ".selector" ).tabs( "option", "disabled", true );
Codesleuth
I don't get it, where did I pass the index of the tab I want to know if it's enabled?..
Nelson
the //getter line will set the value of the variable 'disabled' as a jQuery object. So, if you want to see which one it is, you can request disabled.attr('id'), etc.
Isaac Lubow
and what if there's more than one tab disabled, in that case I think your example wont work..
Nelson
The code I pasted (copied from that link by the way) shows you if a single tab is disabled. If you want to check if **another** tab is disabled, use a different selector. Have you ensured each one of your tabs has a unique ID?
Codesleuth
+2  A: 

The disabled option returns an aray of he indexes of the disabled tabs, so a function to check if one's disabled would look like this:

function isDisabled(index) {
  return $.inArray(index, $("#tabs").tabs("option", "disabled")) > -1;
}

You can give it a try here, this just uses $.inArray() to see if the index is present, just remember the index is 0 based, so the 1st tab is 0, 2nd one is 1, etc.

Nick Craver