HideIfNoKids example?

44 views
Skip to first unread message

Michael Strecke

unread,
Jan 7, 2011, 6:20:19 PM1/7/11
to lif...@googlegroups.com
Hi,

can anyone point me to an example showing the use of "HideIfNoKids"?

I'm trying to make a "top menu entry" disappear if the sub menus are not
reachable (via If or Hidden). I'm guessing this is, what that option
intends to do.

A Google search of the web only points to the API entry.
A search of this newsgroup came up empty.
The various books mention its existence, but nothing more.


I've set up a simple nested menu - using Lift 2.0 - like this:

val testSub1 = Menu(
Loc(
"testsub1",
new Link( List("testpath","suba"), false),
"- sub1")
)

val testSub2 = Menu(
Loc(
"testsub2",
new Link( List("testpath","subb"), false),
"- sub2")
)

val testTopMenu = Menu(
Loc(
"testTop",
new Link( List("testpath"), false),
"Test ..."),
testSub1,
testSub2
)

which works as expected:

The top entry "Test..." loads testpath.html and reveals two sub entries
"- sub1" and "- sub" when clicked upon.

If I hide the two sub menus (via Hidden) or make them not accessible
(using If() ), the "Test..." menu entry still remains.

If I use

val testTopMenu = Menu(
Loc(
"testTop",
new Link( List("testpath"), false),
"Test ...", HideIfNoKids),
testSub1,
testSub2
)

the menu entry disappears even if sub1 and sub2 available.

What did I miss?


Thank you

Michael

Derek Chen-Becker

unread,
Jan 8, 2011, 6:17:23 PM1/8/11
to lif...@googlegroups.com
I think that your interpretation is the intent, so it sounds like a bug. I did some work a month or two ago on the Menu.builder snippet, so it's possible that I broke something when refactoring. Let me look at the code again.

Derek




--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.


Derek Chen-Becker

unread,
Jan 9, 2011, 10:30:59 AM1/9/11
to lif...@googlegroups.com
OK, I tried this out on my local test app and I can't reproduce the bug that you're seeing, but I *am* seeing some other strangeness with HideIfNoKids.

http://www.assembla.com/spaces/liftweb/tickets/832-fix-hideifnokids-so-that-it-works

Derek

On Fri, Jan 7, 2011 at 4:20 PM, Michael Strecke <michael...@googlemail.com> wrote:

Naruki Ikeda

unread,
Sep 30, 2013, 11:43:36 AM9/30/13
to lif...@googlegroups.com
Hi,

I tried in Lift 2.5.1 above example,

    val testSub1 = Menu(
      Loc(
        "testsub1",
        new Link( List("testpath","suba"), false),
        "- sub1")
    )

    val testSub2 = Menu(
      Loc(
        "testsub2",
        new Link( List("testpath","subb"), false),
        "- sub2")
    )

    val testTopMenu = Menu(
      Loc(
        "testTop",
        new Link( List("testpath"), false),
        "Test ...",HideIfNoKids),
      testSub1,
      testSub2
    )

But the this menu entry disappears.
If I don't use "HideIfNoKids",it appears in the menu.
I want to know how to use "HideIfNoKids" with child menu in Lift 2.5.1.

Thank You.

Naruki

Richard Dallaway

unread,
Oct 7, 2013, 2:02:34 PM10/7/13
to liftweb
Hello Naruki

Not everyone will be able to easily see the original messages you've replied to (from 2011).  You might want to re-state what you want to achieve.

In case it helps you move forward, here's an example of HideIfNoKids:

val HasAccount = If(
      () => S.param("showit").isDefined,
      "Get an account!" )

...and a menu of...

 Menu.i("Usually Hidden") / "hide-example" >> HideIfNoKids submenus (
    Menu("Account") / "account" >> HasAccount
  )

If you visit /hide-example the "Usually Hidden" menu will be missing; if you visit /hide-example?showit, you'll see the "Usually Hidden" menu and the sub menu.

Richard




--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
 
---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages