EmberJS - didInsertElement用于以前显示的视图 [英] EmberJS - didInsertElement for previously displayed view

查看:214
本文介绍了EmberJS - didInsertElement用于以前显示的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多页的流程,当我使用'transitionTo'返回到已经显示的路由/视图时,它没有被调用'didInsertElement'方法。 (第一次显示视图时被触发)



是否有一个事件,我的视图可以挂钩,每次显示时都会被调用? / p>

我的路线看起来像这样

  App.Router.map function(){
this.resource(parent,{path:/ parent},function(){
this.resource(child,{path:/ child}) ;
});
});

所以当我在子视图中调用:

  this.transitionTo('parent')

父视图不会触发'didInsertElement'。

解决方案

我发现我可以使用 setupController在路线中每次呈现路线时,让我知道的路线中的我知道这不是最好的解决方案,但到目前为止,这是最可靠的。


I have a flow with multiple pages and when I use 'transitionTo' to go back to a route/view that has already been displayed, it's 'didInsertElement' method is not called. (it was fired the first time the view was displayed, though)

Is there an event that my view can hook into that will be called every time it is displayed?

My routes look something like this

App.Router.map(function() {
    this.resource("parent", { path: "/parent" }, function() {
        this.resource("child", { path: "/child" });
    });
});

So when I'm in the child view and call:

this.transitionTo('parent')

The parent view does not fire 'didInsertElement'.

解决方案

I found that I can use setupController in the routes to let me know each time the route is rendered. I know it's not the best solution, but so far, it is the most reliable.

这篇关于EmberJS - didInsertElement用于以前显示的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆