问题
How can I hightlight the parent menu item of the current page?
I have a site map as follows:
val siteMap = SiteMap(
Menu("Home") / "index",
Menu("Search") / "search" submenus (
Menu("Search Results") / "search-results") >> Hidden)
and I use it as follows:
<lift:Menu.builder ul:class="tabs" li_item:class="selected" />
However, when I navigate to the /search-results - the search menu item is no longer selected (i.e. the css class selected is no longer applied to it).
Any tips?
回答1:
it's quite simple. You should use Lift built-in snippet Menu parameter li_path
something from documentation:
li_path - Adds the specified attribute to the current page’s breadcrumb trail (the breadcrumb trail is the set of menu items that are direct ancestors in the menu tree)
so in your code, you could do just:
<lift:Menu.builder ul:class="tabs" li_item:class="selected" li_path:class="selected" />
Hope this helps. If you could have any other questions just ask :)
来源:https://stackoverflow.com/questions/5993350/how-to-highlight-parent-of-the-current-page