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

Find Tab Before Adding

2 Answers 55 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.
Mark
Top achievements
Rank 1
Mark asked on 30 Nov 2011, 07:13 PM
Hi
I am adding tabs client-side. However, i do not want to create duplicate tabs.
Is there a simple way of detecting if a tab already exists in the tabstrip ?

I have tried to iterate through each tab, but can not figure out how to get text of tab... (see code below)
var textValue;
var index;
var exists = false;
$('#SampleTabStrip a').each(function () {
   textValue= $.data(this, 'tTabStrip');
   if (textValue== newTextValue) { exists = true; index = $(this).attr('text'); }
})
I pass newTextValue into function but my attributes dont seem to be correct for the matching process...

Any ideas please?

Thanks
Mark

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 02 Dec 2011, 12:58 PM
Hi Mark,

 This 
textValue= $.data(this'tTabStrip');

will not get the text of the tab. You need to use the text() jQuery method to get the text content of a html element. Please change your code to this:

$('#SampleTabStrip a').each(function () {
   textValue= $(this).text();
   // ...
}

Kind regards,

Atanas Korchev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Mark
Top achievements
Rank 1
answered on 02 Dec 2011, 01:09 PM
Yes !!
That worked...many Thanks

Mark
Tags
TabStrip
Asked by
Mark
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Mark
Top achievements
Rank 1
Share this question
or