Javascript Meteor Iron路由器等待模板渲染

Javascript Meteor Iron路由器等待模板渲染,javascript,meteor,handlebars.js,iron-router,Javascript,Meteor,Handlebars.js,Iron Router,是否需要等待模板呈现,然后执行特定的函数 我试过了,但没用 Router.map(function () { this.route('post', { path: '/posts/:ll', action: function () { this.render('home'); }, after: function () { var n = this.params.ll UI.insert(UI.render(Templ

是否需要等待模板呈现,然后执行特定的函数

我试过了,但没用

Router.map(function () {
  this.route('post', {
    path: '/posts/:ll',

    action: function () {
      this.render('home');
    },

    after: function () {
      var n = this.params.ll
       UI.insert(UI.render(Template[n]), document.getElementById("child"))
    }
  });
});
结果表明,子元素还不存在,因为启动after函数时“home”模板尚未呈现

非常感谢您的任何建议或解决方法。

您能做到这一点吗:

action: function () {
  this.render('home');
  Template.home.rendered = function() {
    // ...
    Template.home.rendered = null;
  };
},

在动作后使用
而不是在动作后使用


谢谢你,星期五。当时我写了一个问题,这个功能在IronRouter中还不存在。但标记为已为其他人解决。从0.8.3和iron router的最新版本开始,似乎在执行onAfterAction时未呈现模板实例。尝试访问模板元素无效。谢谢!公认的答案对我不起作用,但这确实起了作用