Aurelia-一种在多级下拉菜单中添加分隔线的方法 [英] Aurelia - A way to add a divider into a multi level drop down menu
问题描述
我有一个用于带有引导程序的Aurelia的多级下拉菜单,但是虽然其三个级别很深,并且以此为基础进行扩展,但是我在通过路由设置添加分频器时遇到了麻烦.
I have a multi level dropdown menu working for Aurelia with bootstrap however whilst its three levels deep and uses as a basis THIS gist expanding on it I am having trouble adding a divider via the route settings.
现在,分隔符在列表标记<li></li>
中使用类"divider".好了,我想通过在下拉菜单的设置中添加条目divider: true
,我可以进行检查,如果显示链接等,我可以而是显示一个分隔线,但是我不知道如何将其实现到navmenu.html文件中.这是文件:
Now a divider uses the class "divider" in the list tag <li></li>
Ok so I thought by adding the entry divider: true
in the settings for the dropdown I could check for that and instead if displaying the link etc I could instead show a divider however I dont know how to implement this into the navmenu.html file. Here is the file:
<ul class="nav navbar-nav">
<li repeat.for="route of router.navigation" class="${route.isActive ? 'active' : ''}">
<a href.bind="route.href" if.bind="!route.settings.nav"><span class="glyphicon glyphicon-${ route.settings.icon }"></span> ${route.title}</a>
<a href.bind="route.href" if.bind="route.settings.nav" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-${ route.settings.icon }"></span> ${route.title} <span class="caret"></span> <!--First level menu heading - requires route.settings.nav to exist-->
</a>
<ul if.bind="route.settings.nav" class="dropdown-menu">
<li repeat.for="menu of route.settings.nav" class="dropdown-submenu">
<a href.bind="menu.href" if.bind="!menu.navSettings.subNav"><span class="glyphicon glyphicon-${ menu.navSettings.icon }"></span> ${menu.title}</a>
<a href.bind="menu.href" if.bind="menu.navSettings.subNav" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-${ menu.navSettings.icon }"></span> ${menu.title} <span class="caret-right"></span>
</a>
<ul if.bind="menu.navSettings.subNav" class="dropdown-menu">
<li repeat.for="subMenu of menu.navSettings.subNav" class="dropdown-submenu">
<a href.bind="subMenu.href" if.bind="!subMenu.subNavSettings.subSubNav"><span class="glyphicon glyphicon-${ subMenu.subNavSettings.icon }"></span> ${subMenu.title}</a>
<a href.bind="subMenu.href" if.bind="subMenu.subNavSettings.subSubNav" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-${ subMenu.subNavSettings.icon }"></span> ${subMenu.title} <span class="caret-right"></span>
</a>
<ul if.bind="subMenu.subNavSettings.subSubNav" class="dropdown-menu">
<li repeat.for="lowestSubMenu of subMenu.subNavSettings.subSubNav" class="dropdown-submenu">
<a href.bind="lowestSubMenu.href"> <span class="glyphicon glyphicon-${ lowestSubMenu.subSubNavSettings.icon }"></span> ${lowestSubMenu.title}</a>
</li>
</ul>
</li>
</ul>
</li> [ALL THE ANCHORS HERE OR A DIVIDER.. HOW DO I DO A TERNARY TO CHECK ON EACH REPEAT FOR A DIVIDER VALUE IN THE SETTINGS ARRAY.
</ul>
</li>
</ul>
这是导航菜单从导航图读取的内容:
Here is an exert from the route map that the navmenu reads from:
{
route: "clients",
name: "clients",
moduleId: PLATFORM.moduleName("../components/clients/clientList/clientList"),
title: "Clients",
nav: true,
settings: {
nav: [
{
href: "#clients/clientsList",
title: "Client List",
navSettings: {
icon: "list",
roles: ["Employee", "Admin"],
}
},
{
navSettings: {
roles: ["Employee", "Admin"],
divider: true, // HERE IS MY DIVIDER
}
},
{
href: "#clients/Create",
title: "Create Client",
navSettings: {
icon: "user",
roles: ["Employee", "Admin"],
}
}
],
icon: "user",
auth: true,
roles: ["Employee", "Admin"],
pos: "left"
}
},
问题是<li></li>
做一个重复,我需要检查该重复-li以查看"navSettings是否具有条目分隔符:true,如果不是,则显示链接(菜单项),而是显示一个行分隔线.
The problem is that the <li></li>
does a repeat and I need to check in that repeat - li to see if "navSettings has an entry divider: true and if so not show the link (menu item) but instead show a line divider.
如何丢弃锚点,而是显示带有"divider"类的列表行.让我大吃一惊的是li拥有了repeat.for,我需要显示<li></li>
标记之间的所有内容,或者显示一个分隔符.
How do I discard the anchors and instead show a list line with class "divider". Whats throwing me is the fact that the li has a repeat.for and I need to either show everything between the <li></li>
tags or instead show a divider.
我需要检查以下行:
<li repeat.for="menu of route.settings.nav" class="dropdown-submenu">
并将类从下拉菜单"更改为分隔线",同时通过对分隔线进行类似的检查(如果我猜是if.bind),则不显示任何锚点<a></a>
.
and change the class from "dropdown-submenu" to "divider" while at the same time not show any of the anchors <a></a>
by doing similar check (if.bind I am guessing) for divider..
希望可以为您提供帮助.
Hope you can help..
推荐答案
在<li>
中使用class="${menu.divider ? 'divider' : 'dropdown-submenu'}"
.
对<li>
中的元素使用menu.divider
上的if.bind
.
<li repeat.for="menu of route.settings.nav" class="${menu.divider ? 'divider' : 'dropdown-submenu'}">
<a if.bind="!menu.divider" href.bind="lowestSubMenu.href"> <span class="glyphicon glyphicon-${ lowestSubMenu.subSubNavSettings.icon }"></span> ${lowestSubMenu.title}</a>
<div if.bind="menu.divider" class="divider"></div>
</li>
这篇关于Aurelia-一种在多级下拉菜单中添加分隔线的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!