Meteor onRendered数据不会出现,除非我按“后退”按钮
我在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()
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在您访问时使用。但你是
您必须选择是让模板实例处理订阅还是路由器