I am trying to use the 'pickadate' package in MeteorJS but 'pickadate' changes the date in all template instances instead of just the one where I want.
<body>
<div class="outer">
<h1 class="title">Datepicker</h1>
{{> myTemplate}}
{{> myTemplate}}
{{> myTemplate}}
</div>
</body>
<template name="myTemplate">
<div class="ui myDay button">
{{myDay}}
</div>
</template>
The three 'myTemplate' instances should be independent so I use local reactiveVars. The 'day' reactive variable stores the date, and when the date picker closes, the picker takes the picker's 'highlighted' date, and the 'day' on the myTemplate instance gets set to that date. (In 'picker.on', 'this' refers to the picker.)
Template.myTemplate.helpers({
myDay: function () {
var myDay = Template.instance().day.get();
return moment(myDay).format('ddd YYYY-MM-DD');
}
});
Template.myTemplate.events({
});
Template.myTemplate.onCreated(function () {
this.day = new ReactiveVar(new Date('2015-08-02'));
});
Template.myTemplate.onRendered(function () {
var tmplInstance = this;
var $input = $('div.ui.myDay.button').pickadate({
containerHidden: '#hidden-input-outlet'
});
var picker = $input.pickadate('picker');
picker.on({
close: function() {
tmplInstance.day.set(moment(this.get('highlight').obj)._d);
}
});
});
But for some reason the new date gets set on all three instances instead of just the one that I use the pickadate on.
The code is on meteorpad.com, where the buttons won't show up but you can click on the dates.
The question is how to make the buttons' date picker work independently.