Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Index of Activated Tab

I'm upgrading code from jQuery UI 1.8 to 1.10.

Under 1.8, the event triggered when the tab changes was select, and I could access the index of the tab being selected through ui.index.

Under 1.10, the event triggered when the tab changes is activate. However, I cannot find anything in the event parameter ui that tells me the index of the newly activated tab.

How can I discover that index?

like image 815
Eric J. Avatar asked Mar 12 '13 16:03

Eric J.


People also ask

How do I get the selected tab index?

It returns the previously selected tab index, not the new one: var selectedTab = $("#TabList"). tabs(). data("selected.

How to get active tab value in jquery?

live("click", function(){ var ref_this = $("ul. tabs li a"). find(". active"); alert(ref_this.

How to get selected tab index in jquery?

click('tabsselect', function (event, ui) { var selectedTab = $("#tabs"). tabs('option', 'active'); $("#hidLastTab"). val(selectedTab); });


1 Answers

You could use the following approach http://jsfiddle.net/9ChL5/1/:

$("#tabs").tabs({
    activate: function (event, ui) {

        console.log(ui.newTab.index());
    }
});
like image 129
Justin Bicknell Avatar answered Sep 28 '22 17:09

Justin Bicknell