简体   繁体   English

如何通过按下余烬中的后退按钮从插座中删除视图?

[英]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: 使用当前版本的ember路由器,您可以定义路由处理程序,如下所示:

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). 但是,从路由器v2开始,disconnectOutlet方法不再起作用(我假设因为它与connectOutlet方法一起集中在一起)。

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 . 在离开一条路线时, Ember扯下了视线 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! 但是, exit不再是公共挂钩,并且因为你没有调用super ,你对如何拆除视图的错误猜测是破坏了内置行为!

If you remove the exit call, everything should work as you expect. 如果您删除了exit呼叫,一切都应该按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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