我正在使用以下引导程序导航侧边栏和metisMenu jquery库:
<div id="Sidebar" class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">
<li>
<a href="/Dashboard"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a>
</li>
<li>
<a href='#'>
<i class='fa fa-calendar fa-fw'></i> Diary<span class='glyphicon arrow'></span>
</a>
<ul class='nav nav-second-level'>
<li>
<a href="/Diary/Index?diaryModeId=1">My Actions</a>
</li>
</ul>
</li>
<li>
<a href='#'>
<i class='fa fa-pie-chart fa-fw'></i> MI<span class='glyphicon arrow'></span>
</a>
<ul class='nav nav-second-level'>
<li>
<a href="/MI/EntityStatus">Entity Status</a>
</li>
</ul>
</li>
<li>
<a href='#'>
<i class='fa fa-cogs fa-fw'></i> Administration<span class='glyphicon arrow'></span>
</a>
<ul class='nav nav-second-level'>
<li>
<a href='#'>
Question Admin<span class='fa plus-minus'></span>
</a>
<ul class='nav nav-third-level'>
<li>
<a href="/Rule/Index">Business Rules</a>
</li>
<li>
<a href="/Question/Index">Question Bank</a>
</li>
</ul>
</li>
<li>
<a href='#'>
User Admin<span class='fa plus-minus'></span>
</a>
<ul class='nav nav-third-level'>
<li>
<a href="/User/Index">Users</a>
</li>
<li>
<a href="/Team/Index">Teams</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
我在刷新时运行以下代码:
$(function () {
$('#side-menu').metisMenu();
});
级别1和级别2选择在菜单折叠然后重新选择所选菜单选项时正常工作。当我选择3级项目(例如问题库)时,菜单会折叠但不会重新选择。我还需要做些什么吗?我的html标记是否正确?
答案 0 :(得分:1)
对于第三级菜单项(或任何级别菜单项),您需要确保其所有祖先li
项都有class="active"
。