Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#6226 closed enhancement (wontfix)

Menu: API enhancements

Reported by: alex Owned by: bill
Priority: high Milestone: 1.4
Component: Dijit Version: 1.0
Keywords: menu, dijit Cc:
Blocked By: Blocking:

Description (last modified by bill)

I've been working with dijit.Menu this evening, and it's really making me scratch my head about a couple of design choices.

First, there's no open() or close() methods. Instead, one must pass an instance of the Menu into dijit.popup.open() or dijit.popup.close(). This is (to say the least) unintuitive.

Secondly, I expect that menus will be re-used often, and while there's a programmatic example of adding items to a menu, no example is provided for how to remove them, nor is there a "clear()" method or similar for removing dijit.MenuItem?() instance. Similarly, there isn't a uniform "remove from parent" (not destroy()) method on MenuItem? instances.

Lastly, it would seem that the construction of a set of menu items is the common case. Supporting a JSON-style syntax for describing a set of items and their generic properties seems useful for constructing trees of menus.

Change History (3)

comment:1 Changed 11 years ago by bill

Milestone: 1.21.4
Owner: set to bill
Summary: dijit.Menu API odditiesMenu: API enhancements

The open()/close() thing is by design, a fallout from Dylan's idea that any widget should be able to be used as a popup.. thus widgets themselves don't have open/close methods. Will consider the other stuff.

comment:2 in reply to:  description Changed 11 years ago by bill

Description: modified (diff)
Resolution: wontfix
Status: newclosed
Type: defectenhancement

Replying to alex:

Secondly, I expect that menus will be re-used often, and while there's a programmatic example of adding items to a menu, no example is provided for how to remove them, nor is there a "clear()" method or similar for removing dijit.MenuItem?() instance. Similarly, there isn't a uniform "remove from parent" (not destroy()) method on MenuItem? instances.

Menu.removeChild(MenuItem?) should work, doesn't it?

Lastly, it would seem that the construction of a set of menu items is the common case. Supporting a JSON-style syntax for describing a set of items and their generic properties seems useful for constructing trees of menus.

I agree that's a common case, although it can easily be done by code outside of menu. I don't see the benefit of adding it to Menu itself, although that's debatable. There's also a possibility of dojo.data integration... if you think about it Menus and Trees are similar in their hierarchical structure, and trees work off of dojo.data.

Anyway, I'm going to close this ER for now.

comment:3 Changed 11 years ago by bill

PS: see #7382 for menu generation from JSON.

Note: See TracTickets for help on using tickets.