[英]How do I get a reference to the currently selected tab in a Kendo UI TabStrip?
I'm creating a method to delete a Kendo UI TabStrip Tab based on an 'x' image. 我正在创建一种方法来删除基于“x”图像的Kendo UI TabStrip选项卡。 I want it to work in the same way as other tab controls (such as Chrome/IE): 我想让它以与其他标签控件(例如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
? 我可以通过搜索k-state-active
来做到这一点吗?
tabstrip.select()
将返回当前选定的选项卡。
tabStrip.select().index();
将返回当前选中的选项卡索引
To get the currently selected tab of the tabstrip, you can use: 要获取tabstrip的当前选定选项卡,您可以使用:
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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.