Recent Posts
- (09/10) Fixing Warning: the ECDSA host key for 'github.com' differs from the key for the IP addressTAGS:Web Server Admin
- (12/26) CakePHP 3 - Getting List of Column Definitions from a Table (like schema())TAGS:CakephpCake3
- (09/14) Change Order of Loaded Behaviors in CakePHP 3TAGS:Cake3CakephpWeb ProgrammingPhp
- (05/29) CakePHP 3 - Accept JSON Header Only Working When Debug FalseTAGS:Web ProgrammingCakephpCake3
- (05/23) Remove All Events from Google Calendar (Reset Calendar)TAGS:Web ProgrammingPhp
- (11/08) Google Tag Manager (GTM) Not Firing Default PageView EventTAGS:Web ProgrammingJavascriptGoogle Tag Manager
- (10/13) In PHP, how do you get __toString() Magic Method Result without calling echo?TAGS:CakephpCake3Cakephp 13PhpWeb Programming
- (11/14) Getting output from shell_exec() at all timesTAGS:Web ProgrammingWeb Server Admin
Subscribe to my feed
MainelyDesign.com Blog
jQuery UI 1.10 Tabs - Getting Index of Current Tab
Posted on 03/18/2013 at 10:00 pm by Kevin Wentworth
Viewed 18,444 times | 0 comments
I remember being able to get the index of the current tab very easily from jQuery UI, something like ui.panel.index. I couldn't find it in my code and figured out the way to do it with jQuery UI 1.10
Determining the Current Tab Index
Most of the documentation and examples for JQuery UI keep using the same basic code that doesn't really work if you have more than one tabbed-interface on any of your web pages. The jQuery UI documentation tells you to do this:
- // getter
- var active = $( ".selector" ).tabs( "option", "active" );
Getting the Tab Index of the Currently Active Tab
The above will work fine if you have a single div.selector on your page. However, if you have multiple tab sets, I've found the easiest solution is the following:
- // this will work in any callback function - activate() or load()
- var $thisTabContainer = ui.newTab.closest('.ui-tabs');
- var active = $thisTabContainer.tabs("option", "active");
That way, no matter how many different configurations of tabs you may have on a page, you will always get the current tab.
Cheers,
-Kevin Wentworth
Tags for jQuery UI 1.10 Tabs - Getting Index of Current Tab
Ui | Upgrade | Web Programming | Example
Comments for this Posting
No comments. Be the first to post a reply.
Sorry, comments are closed for this posting.
Please Email Kevin if you have any questions. Thanks!