Hi!
I just migrate my subscriptions from IronRouter to my templates. It’s working but I have a problem.
On mly template sessionDate, I subscribe to the sessionDate I have to display:
Template.sessionDate.onCreated(function () {
this.autorun(() => {
const sessionID = Router.current().params._ID;
this.subscribe( 'sessionDates.one', sessionID );
});
});
Then I made a template helper to access to the data of this sessionDate (maybe this is not the good way):
Template.sessionDate.helpers({
"sessionDate": function(){
const sessionID = Router.current().params._ID;
var sessionToDisplay = Sessions.findOne({ "_id": sessionID });
var sessionDate = SessionDates.findOne({ sessionID: sessionID, last: true });
sessionDate.infos = sessionToDisplay;
return sessionDate;
},
});
So in my template I always call the helper to have access to the sessionDate data. BUT now I’m stuck with a template event that need some of this sessionDate data…
Template.sessionDate.events({
'click .session-menu .share-session': function (event, instance) {
Router.go('session.share', { _ID: sessionDate.infos._id });
// sessionDate is undefined!
},
});
How can I access to the sessionDate data in this event function?
Thanks for any help!