On 22 Okt., 19:52, fasterthanlight <[EMAIL PROTECTED]>
wrote:
> Aight,
>
> so I'm implementing some awesome jQuery tab action,
>
> I'm trying to pull an index, in that tab the first would be 0, 2nd
> would be 1, and so on and so forth.
> I need to be able to determine which tab is currently selected out of
> the total number so that I can do some next stuff based on that.
>
> The problem is, the built in jQuery way of doing that is this:
>
> var $tabs = $('#example').tabs();
> var selected = $tabs.data('selected.tabs');
>
> and when you output that, it SHOULD return the index number of
> whatever is selected, but its not.
>
> If I click the 3rd tab, it assigns it as 0, i click the 4th, it
> assigns as 1,
> its basing this off of what you click first, which is absolutely
> WRONG, as I can't rely on the user clicking through the tabs in a
> linear fashion, they are tabs after all.

It's not wrong (no need to shout). I'll explain why: The tabs select
handler may cancel the selection of the clicked tab if it returns
false. Thus at the time of execution the property selected.tabs is not
yet updated. You can either use the show handler to rely on that
property or you can use the index property as part of the ui object
passed to the handler to retrieve the proper index of the tab being
clicked.

var $tabs = $('#example').tabs({
    select: function(e, ui) {
        alert(ui.index ===  $tabs.data('selected.tabs')); // => false
    }
});


--Klaus
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to