samedi 31 janvier 2015

Session.set() upon route event in Meteor


I have this functionality associated with clicking a button:



'click .single-speaker-info a': function(ev, speaker){
ev.preventDefault();
Session.set('selectedDocId', this._id);
}


But I'd like it to happen upon hitting this route



Router.route('speaker', {
path:'/speakers/:_id',
template: 'speaker',
data: function(){
return Speakers.findOne(this.params._id);
},

//my attempted solution
selectedDocId: function(){
Session.set('selectedDocId', this._id);
}
});


But I can't find any documentation on how to execute a method on a route.


Here is the Template.helper Im using to get the property Im setting



Template.speaker.helpers({

editingDoc: function(){
return Speakers.findOne({_id: Session.get('selectedDocId')});
}

});




Aucun commentaire:

Enregistrer un commentaire