Skip to content

Instantly share code, notes, and snippets.

@knownasilya
Last active January 2, 2016 03:39
Show Gist options
  • Save knownasilya/8245382 to your computer and use it in GitHub Desktop.
Save knownasilya/8245382 to your computer and use it in GitHub Desktop.

menuu

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment