This is a migrated thread and some comments may be shown as answers.

[Solved] Tabstrip: how to get the selected tab?

4 Answers 419 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
nachid
Top achievements
Rank 1
nachid asked on 29 Mar 2010, 08:14 PM

I am using the tabstrip and wondering how to catch the selected tab in the Select event

My pseudo code looks like :

.ClientEvents(events => events.OnSelect(() => {  %> function(e) {
                                                                                                         if (SelectedTab == "Tab-3" )
                                                                                                              doSomething();
                                                                                                      }   
                                                                                 <% 
                                                                              }
                                           )

Here I don't know how to access the Selected Tab

I am used to jQuery UI Tabs and there fonction events have two parameters

function(event, ui)
{
    if (ui.index == 3)
      doSomething()
}

Thank you for your help

 

4 Answers, 1 is accepted

Sort by
0
Joshua Holt
Top achievements
Rank 2
answered on 29 Mar 2010, 08:49 PM
Hello,
You can get the current selected tab in the OnSelect method like:
function(e)   
{    
    var selectedTab = $(e.item);   
    var selectedTabText = selectedTab.find('> .t-link').text();   
    if ( selectedTabText == "Tab-3" )  
        doSomething();  
}     

You can read more information on this demo.

Hope this helps :)

-Josh

0
nachid
Top achievements
Rank 1
answered on 29 Mar 2010, 09:42 PM
Thanks Joshua,
Actually,  your solution works for the tab name
function(e)   
{    
    var selectedTab = $(e.item);   
    if ( selectedTab.Text() == "Tab-3" )  
        doSomething();  
}  

But I still did find the way to have the index tab
something like this  

function(e)   
{    
    var selectedTab = $(e.item);   
    if ( selectedTab.Index() == 3 )  
        doSomething();  
} 
0
Alex Gyoshev
Telerik team
answered on 30 Mar 2010, 08:57 AM
Hello Nachid,

You can find out the item index like this (the same as your example, just the "index" function should be lowercase):

        function onSelect(e) {
            var item = $(e.item);
            alert(item.index());
        }


Greetings,
Alex Gyoshev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
nachid
Top achievements
Rank 1
answered on 30 Mar 2010, 10:57 AM
Thank you so much Alex
That's exactly what I was looking for

regards
nachid
Tags
TabStrip
Asked by
nachid
Top achievements
Rank 1
Answers by
Joshua Holt
Top achievements
Rank 2
nachid
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or