Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo UI TabStrip - Selecting a tab by it's Text

I am trying to select a tab in javascript when I only know the Text of the tab

I know to get the Selected Tab I do this:

var tabStrip = $("#tabMain").data("kendoTabStrip");
var tab = tabStrip.select();

How do I cause the Selected Tab to be the one with the text "MyTitle"

Note: I create the Tab with MVC 4

    @(Html.Kendo().TabStrip()
          .Name("tabMain")
          .Items(items =>
              {
                  items.Add().Text("MyTitle")
like image 553
Ian Vink Avatar asked Mar 28 '13 17:03

Ian Vink


3 Answers

Basically you need to find the li.k-item and pass it to the select method. Here comes the jQuery:

var ts = $('#tabstrip').data().kendoTabStrip;
var item = ts.tabGroup.find(':contains("What you look for")');
ts.select(item);
like image 137
Petur Subev Avatar answered Nov 06 '22 16:11

Petur Subev


$(document).ready(function(){
      $j("#tabstrip").kendoTabStrip( {
          animation:    {
              open: {
                  effects: "fadein"
              }
          },
    select: function(element){selecttab(element)}           
      });
function selecttab(element) {
        var tabStrip1 = $('#tabstrip').kendoTabStrip().data("kendoTabStrip");
        tabStrip1.select("li:contains(" + $(element.item).text()+ ")");

}            
like image 26
Mayur Kukadiya Avatar answered Nov 06 '22 15:11

Mayur Kukadiya


i tried this - just plain jquery, seems to be working for now in chrome...

var selectedTabName = $("li[aria-selected='true']").text();

like image 40
Kcats Wolfrevo Avatar answered Nov 06 '22 17:11

Kcats Wolfrevo