Search code examples
ember.jsember-old-router

How you do you remove a view from an outlet by pressing the back button in ember?


With the current version of the ember router, you can define a route handler like so:

App.HomeRoute = Ember.Route.extend({
  renderTemplate: function() {
    this.render('home', {into: "application", outlet: "body"});
  }
});

Older builds would allow you to disconnect a view from an outlet on the exit state of a route like this:

exit: function(router){
  router.get('applicationController').disconnectOutlet('chatroom');
}

However, as of router v2, the disconnectOutlet method no longer works (I assume because it was lumped together with the connectOutlet(s) method(s).

So how do you disconnect a view now? Are you supposed to render a blank template into the outlet?


Solution

  • This should actually "just work".

    On exiting a route, Ember tears down the view. However, exit is no longer a public hook, and because you are not calling super, your incorrect guess about how to tear down the view is clobbering the built-in behavior!

    If you remove the exit call, everything should work as you expect.