Reputation: 2273
I'm creating a method to delete a Kendo UI TabStrip Tab based on an 'x' image. I want it to work in the same way as other tab controls (such as Chrome/IE):
I believe I need to get a reference to the current tab, then check if the tab being deleted is the active tab.
My code at the moment simply closes the tab in relation to the clicked image:
function DeleteTab(imgObj) {
var tabStrip = $("#tabstrip").data("kendoTabStrip");
var deleteIndex = $(imgObj).closest("li").index();
tabStrip.remove(deleteIndex);
}
How do I get a reference to the currently selected tab? Can I do this by searching for k-state-active
?
Upvotes: 9
Views: 25102
Reputation: 10141
To get the currently selected tab of the tabstrip, you can use:
var selectedTabElem = $("#tabstripElemId").data('kendoTabStrip').select();// this will be the <li> element that is currently selected
Then one can access the current tab text as below:
var currentSelectedTabText = $(selectedTabElem).children(".k-link").text();
Upvotes: 1
Reputation: 349
tabStrip.select().index();
Will return currently selected tab index
Upvotes: 11