Currently those menus each either
- open a route
- open a submenu
-
- has list of routes
-
- does something more complicated
At the moment I have a SidebarController
/SidebarView
which have a ContainerView
. I currently swap out the views based on a data-view
attribute on each menu link. I use something like this to switch them out.
showMenu: function (event, contentView) {
var $this = $(event.target),
lastViewId = this.get('lastMenu'),
view;
if (!$this.is('a')) {
$this = $this.closest('a');
}
view = this.container.lookup('view:' + $this.attr('data-view'));
contentView.removeAllChildren();
if (view && view.get('elementId') !== lastViewId) {
contentView.pushObject(view);
this.set('lastMenu', view.get('elementId'));
}
else {
this.set('lastMenu', '');
}
},
Preferably I want to have a controller for each submenu. Looking for a good pattern to do that.