I'm using iron-router's data
function to provide data to my HTML template.
snippet from router.js:
data: function() {
liveData = {
dataA: Collection.findOne({queryA}),
dataB: Collection.findOne({queryB})
};
return liveData;
}
Within my template, the liveData
object is reactive. When the Collection changes, liveData changes - great!
But my question: I have a javascript function called computation()
within Template.name.rendered
which uses the liveData
object. It runs once on page load - great - but after the page is loaded, liveData
is changing but the computation is not being re-run. How do I force computation()
to re-run when iron-router's data source, liveData
, changes?
Template.name.rendered = function(){
this.autorun(function(){
var data = Router.current().data();
computation(data);
});
}