Kendo TabStrip: Getting the Selected Index on the

2019-04-10 13:15发布

问题:

My TabStrip is as follows:

        @(Html.Kendo().TabStrip()
              .Name("tabApplications")
              .Items(items =>
                  {
                      items.Add().Text("Online").Selected(true);
                      items.Add().Text("Trading");
                  })
              .Animation(false)
              .Events(e=>e.Select("tabstrip_select"))
              )

In Javascript I get theSelected Item:

     function tabstrip_select(e) {
         var x = e.item;
     }

Question: How do I get the Selected Index (ie "1") from this function. I looked over the Item object but didn't see anything obvious.

回答1:

You can get the currently selected index with calling index() on the $(e.item)

function tabstrip_select(e) {
    var x = e.item;
    var selectedIndex = $(e.item).index();
}

Demo using JSFiddle.