How to highlight parent of the current page?

牧云@^-^@ 提交于 2019-12-22 00:41:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!