creating sub menus?

8 views
Skip to first unread message

Andrew Wooldridge

unread,
Nov 20, 2009, 2:10:16 PM11/20/09
to mozilla-labs-jetpack
I want to create a menu item that has sub menu items - is this
possible? It seems better than adding a bunch of top level menu items
just for one "app".

Drew

unread,
Nov 20, 2009, 4:51:10 PM11/20/09
to mozilla-la...@googlegroups.com
Try the "menu" property of menuitems:

var menuitem = {
label: "Submenu",
menu: new jetpack.Menu([
{ label: "Another Submenu!", menu: new jetpack.Menu(...) }
])
};
jetpack.menu.set(menuitem);

https://developer.mozilla.org/en/Jetpack/UI/Menu#Properties_2

Drew
> --
>
> You received this message because you are subscribed to the Google Groups "mozilla-labs-jetpack" group.
> To post to this group, send email to mozilla-la...@googlegroups.com.
> To unsubscribe from this group, send email to mozilla-labs-jet...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mozilla-labs-jetpack?hl=.
>
>

Aza

unread,
Nov 20, 2009, 8:50:18 PM11/20/09
to mozilla-la...@googlegroups.com
Is there any reason why we have to make that extra object? Should this be able to work too?

var menuitem = {
  label: "Submenu",
  menu: [

    { label: "Another Submenu!", menu: new jetpack.Menu(...) }
  ]
};
jetpack.menu.set(menuitem);

-- aza | ɐzɐ --

Drew

unread,
Nov 20, 2009, 8:59:52 PM11/20/09
to mozilla-la...@googlegroups.com
Yeah, I've had the same thought. The reason the jetpack.Menu
constructor exists is because menus have specialized methods. So you
can for example:

var myMenu = new jetpack.Menu();
myMenu.add("foo");
jetpack.menu.set({ label: "My Menu", menu: myMenu });

We could just box the |menu| value if it's not already a jetpack.Menu,
but I chose not to because in one sense it's more complex: Sometimes
you have to write jetpack.Menu, sometimes you don't. But you're right,
it does make code more terse if you don't have to write it.

What do you think?

Drew
> <mailto:mozilla-la...@googlegroups.com>.
> > To unsubscribe from this group, send email to
> mozilla-labs-jet...@googlegroups.com
> <mailto:mozilla-labs-jetpack%2Bunsu...@googlegroups.com>.
> > For more options, visit this group at
> http://groups.google.com/group/mozilla-labs-jetpack?hl=.
> >
> >
>
> --
>
> You received this message because you are subscribed to the Google
> Groups "mozilla-labs-jetpack" group.
> To post to this group, send email to
> mozilla-la...@googlegroups.com
> <mailto:mozilla-la...@googlegroups.com>.
> To unsubscribe from this group, send email to
> mozilla-labs-jet...@googlegroups.com
> <mailto:mozilla-labs-jetpack%2Bunsu...@googlegroups.com>.

Aza

unread,
Nov 21, 2009, 5:10:14 AM11/21/09
to mozilla-la...@googlegroups.com
I think of it as graceful upgradation; only when you need the power do you level-up the syntax.

-- aza | ɐzɐ --

Erik Vold

unread,
Nov 21, 2009, 10:48:07 PM11/21/09
to mozilla-labs-jetpack
I don't think it would be more complex, it's like what String.replace
does, so it's a concept a js developer would be used to.

Erik
Reply all
Reply to author
Forward
0 new messages