Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor onRendered数据不会出现,除非我按“后退”按钮_Meteor_Iron Router - Fatal编程技术网

Meteor onRendered数据不会出现,除非我按“后退”按钮

Meteor onRendered数据不会出现,除非我按“后退”按钮,meteor,iron-router,Meteor,Iron Router,我在onRendered事件中有一些功能,我希望在每个渲染中运行这些功能 Template.DashboardCoachPost.onRendered(function () { var post, postId; this.autorun(function() { postId = Router.current().params.query.p; reactive.isSubmitted.set(false); if (Template.instance()

我在onRendered事件中有一些功能,我希望在每个渲染中运行这些功能

Template.DashboardCoachPost.onRendered(function () {
  var post, postId;

  this.autorun(function() {
    postId = Router.current().params.query.p;
    reactive.isSubmitted.set(false);

    if (Template.instance().subscriptionsReady()) {
      post = Posts.find({_id: postId}).fetch()[0];
      reactive.post.set(post);

      if (post) {
        reactive.isSubmitted.set(true);  
      }
    }
  });
});
在我的RouterController中,我有:

DashboardCoachPostController = RouteController.extend({
  subscriptions: function() {
    this.postId = Router.current().params.query.p;

    if (this.handle) {
      this.handle.stop();
    }

    if (this.postId) {
      this.handle = this.subscribe('posts', { postId: this.postId });
    }
  }
});
我的路线是:

Router.route('/dashboard/coach/post', {
    name: 'dashboardCoachPost',
    controller: DashboardCoachPostController,
    where: 'client',
    layoutTemplate: 'LegalLayout'
});
我有一种感觉,我没有正确地处理订阅,但是如果没有这种方法,我无法找到如何获取我的帖子。

Template.instance.subscriptionsReady在您访问时使用。但你是

您必须选择是让模板实例处理订阅还是路由器