Javascript 如何隐藏*single*MVC/Kendo选项卡Strip选项卡?
如何在MVC/Kendo UI tabstrip上隐藏单个选项卡 我想根据条件隐藏选项卡。我的jQuery代码如下所示:Javascript 如何隐藏*single*MVC/Kendo选项卡Strip选项卡?,javascript,jquery,kendo-ui,telerik,Javascript,Jquery,Kendo Ui,Telerik,如何在MVC/Kendo UI tabstrip上隐藏单个选项卡 我想根据条件隐藏选项卡。我的jQuery代码如下所示: //authUser is a hidden input whose value is set in the controller and passed into the view if ($('#authUser').val() == 'False') //hide the last tab { $
//authUser is a hidden input whose value is set in the controller and passed into the view
if ($('#authUser').val() == 'False') //hide the last tab
{
$($("#tabstrip").data("kendoTabStrip").items()[6]).attr("style", "display:none");
}
当我运行代码时,如果authUser为False,则在执行的代码行上会出现以下错误:
JavaScript运行时错误:无法获取未定义或空引用的属性“items”
想法?未定义“项目”这一事实意味着您从一开始就没有正确选择tabstrip。要么你的CSS选择器错了,你确定你把它命名为tabstrip吗?或者您没有正确地遵循剑道方法名称 以下是我发现的两种隐藏最后一个选项卡的方法: 隐藏最后一个tabstrip元素 使用剑道的tabstrip移除方法 我认为以下几点更为恰当。为什么不使用tabstrip的remove方法并将其从DOM中完全移除,因为用户无论如何都不应该具有访问权限
var tabStrip = $("#tabstrip").kendoTabStrip().data("kendoTabStrip");
tabStrip.remove("li:last");
我只是个傻瓜。。。。
我看了更多的代码,我把kendoTabStrip这个粗体字删掉了
$$tabstrip.kendoTabstrip.datakendoTabStrip.items[6]。属性样式,显示:无
i、 e.不适当地拥有:
$($("#tabstrip").kendoTabStrip().data("kendoTabStrip").items()[6]).attr("style","display:none")
我有:
$($("#tabstrip").data("kendoTabStrip").items()[6]).attr("style","display:none")
德鲁,谢谢你的努力。有时我不得不在墙上敲打我的头,直到我看到我做了什么。如果使用第一种方法,还要确保检查该选项卡是否选中,如果选中,请选择另一个选项卡。如果隐藏的选项卡是活动选项卡,则在激活另一个选项卡之前,内容仍将显示在选项卡面板中。
$($("#tabstrip").data("kendoTabStrip").items()[6]).attr("style","display:none")