我有与此处描述的完全相同的问题:
http://bugs.jqueryui.com/ticket/7930.问题是维护者无法重现它,因此票证已关闭.我的代码如下:
<script type="text/javascript">
$(document).ready(function () {
// assigns the value of a GET parameter called tab to tabIndex
var tabIndex = getUrlVars()['tab'];
if (isNaN(tabIndex)) {
tabIndex = 0;
}
// initializes tabs and selects the one provided in tabIndex (default: 0)
$('div#tabs').tabs({ ajaxOptions: { cache: false},selected: tabIndex });
});
</script>
<div id="tabs">
<ul>
<li>@Html.ActionLink("User roles","Roles","Admin",New With {.rand = DateTime.Now.Ticks},nothing)</li>
<li>@Html.ActionLink("Report templates","Reports",nothing)</li>
<li>@Html.ActionLink("Blabla","2","Admin")</li>
<li>@Html.ActionLink("Blabla2","3","Admin")</li>
</ul>
</div>
这将使用id创建标签:#ui-tabs-1,#ui-tabs-2,#ui-tabs-3,#ui-tabs-4.我通过url:http://server/Admin?tab=1访问该页面.选择了相应的选项卡(第二个带有报告),但是对前一个选项卡(用户角色)的href进行了ajax调用.它会导致显示空标签内容.你知道怎么解决吗?
解决方法
我用了:
$(‘#tabs’).tabs({selected:tabIndex});
但tabIndex是一个字符串(我从url或url hash获取它),因此导致例如:
$(‘#tabs’).tabs({selected:“2”});
在这种情况下,您可以观察到这种意外行为.
在tabIndex上调用Number函数
tabIndex = Number(tabIndex)
解决了这个问题.