jQueryUI Accordian Menu - 如何处理没有子菜单的项目
我有一个使用 jQueryUI 的 Accordian 方法的垂直菜单。前两个项目有子菜单,其余项目则没有。我还将事件设置为“悬停”而不是“单击”。
问题:是,当您将鼠标悬停在任何没有子菜单的项目上时,它会隐藏带有子菜单的项目。有没有办法让它始终保持至少一个项目的子菜单打开?或者另一种说法:有没有办法强制没有子菜单的项目不折叠任何其他项目?
这是我的菜单的一个例子......
<ul class="nav" id="menu_left">
<li class="expand"><a href="/category" class="current head">products</a>
<ul>
<li class="top png first"></li>
<li><a href="/category/523">Category</a></li>
<li><a href="/category/428" >Category</a></li>
<li><a href="/category/498">Category</a></li>
<li class="space"><div></div><a href="/category/507">Category</a></li>
<li><a href="/category/">Category</a></li>
<li><a href="#">Category</a></li>
<li><a href="#">Category</a></li>
<li class="space"><div></div><a href="#">Category</a></li>
<li><a href="#">Category</a></li>
<li class="bottom png"></li>
</ul>
</li>
<li class="expand"><a href="/category/">custom</a>
<ul>
<li class="top png first"></li>
<li><a href="/category">Category</a></li>
<li class="space"><div></div><a href="/category/428" >Category</a></li>
<li><a href="/category/498">Category</a></li>
<li class="bottom png"></li>
</ul>
</li>
<li><a href="javascript:void(0);" class="head" >Contact</a></li>
<li><a href="javascript:void(0);" class="head">Blog</a></li>
<li><a href="javascript:void(0);" class="head">Feature</a></li>
</ul>
$('#menu_left').accordion({
active: 0,
autoHeight: true,
animated: 'slide',
event: 'mouseover',
header: "> li > :first-child,> :not(li):even",
collapsible: false,
navigationFilter: function() {
return this.href.toLowerCase() == location.href.toLowerCase();
}
});
I've got a vertical menu using jQueryUI's Accordian method. The first two items have sub-menus and then the rest don't. I also have the event set to 'hover' instead of 'click'.
The problem: is that when you hover over any of the items with no sub-menus, then it hides the one with a sub-menu. Is there a way I can make it so it always keeps at least one item with a sub-menu open? Or another way to say this: is there a way to force items with no sub-menus to not collapse any other items?
Here's an example of my menu...
<ul class="nav" id="menu_left">
<li class="expand"><a href="/category" class="current head">products</a>
<ul>
<li class="top png first"></li>
<li><a href="/category/523">Category</a></li>
<li><a href="/category/428" >Category</a></li>
<li><a href="/category/498">Category</a></li>
<li class="space"><div></div><a href="/category/507">Category</a></li>
<li><a href="/category/">Category</a></li>
<li><a href="#">Category</a></li>
<li><a href="#">Category</a></li>
<li class="space"><div></div><a href="#">Category</a></li>
<li><a href="#">Category</a></li>
<li class="bottom png"></li>
</ul>
</li>
<li class="expand"><a href="/category/">custom</a>
<ul>
<li class="top png first"></li>
<li><a href="/category">Category</a></li>
<li class="space"><div></div><a href="/category/428" >Category</a></li>
<li><a href="/category/498">Category</a></li>
<li class="bottom png"></li>
</ul>
</li>
<li><a href="javascript:void(0);" class="head" >Contact</a></li>
<li><a href="javascript:void(0);" class="head">Blog</a></li>
<li><a href="javascript:void(0);" class="head">Feature</a></li>
</ul>
$('#menu_left').accordion({
active: 0,
autoHeight: true,
animated: 'slide',
event: 'mouseover',
header: "> li > :first-child,> :not(li):even",
collapsible: false,
navigationFilter: function() {
return this.href.toLowerCase() == location.href.toLowerCase();
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以有两个单独的菜单,并将其样式设置为看起来像一个。
You could have two separate menus, and just style it to look like one.
我通过将标题选项更改为如下解决了这个问题...
我还将 autoHeight 更改为 false...
I solved this by changing the header option to look like this...
I also changed autoHeight to false...