I am using
Template.taskList.onCreated( () => {
var projectId = FlowRouter.getParam( 'projectId' );
var postHooks = {
before: {
insert: function ( doc ) {
doc.projectId = projectId;
return doc;
}
}
};
Template.instance().subscribe( 'tasks', projectId );
AutoForm.addHooks( 'addTask', postHooks );
} );
to add projectId
to all created tasks and subscribe to tasks with the specified projectId
.
However, when I change the projectId
with FlowRouter.setParam( 'projectId' ... )
, it seems projectId
is not changing in my hook and subscription.
What am I doing wrong? Do I have to put it inside Tracker.autorun()
or something? Is it because I use onCreated
instead of onRendered
?