开发者

How to highlight parent of the current page?

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?


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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜