简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM