I'm working on a shared calendar app. I have the following (simplified) template structure:
<template name="meeting">
{{> calendar}}
</template>
<template name="calendar">
{{#each days}}
{{> day}}
{{/each}}
</template>
<template name="day">
etc etc
</template>
I have a ReactiveVar for the state of each day that's setup like so:
Template.day.created = function(){
this.state = new ReactiveVar();
this.autorun(_.bind(function() {
var thisDate = Meetings.findOne(this.data._id).dates[this.data.dateString];
s = ...various stuff...
this.state.set(s);
}, this));
}
And routes set up like so (I'm using my own uuids instead of Mongo ids for public urls):
Router.map(function () {
this.route('home', {path: '/'});
this.route('meeting', {
path: '/meeting/:uuid',
template: 'meeting',
data: function() {
return Meetings.findOne({"uuid":this.params.uuid});
}
});
});
The core problem as I understand it is that Template.day.created does not have a data context (yet), so I need a way to pass in the _id (or uuid) of the meeting. What is the right approach for providing this context?