mercredi 25 février 2015

Session.set inside lib directory in Meteor

I have my iron-router code in my top-level lib directory in a file called routes.js. In that file I make calls to the front-end Session variable, specifically inside my onBeforeAction method like so:



Router.map(function () {

this.route('homeTemplate',{
name: 'homeTemplate',
where: 'client',
path: '/',
load: function() {
$('html, body').animate({
scrollTop: 0
}, 400);
return $('.content').hide().fadeIn(1000);
},
waitOn: function() {
return Meteor.subscribe(COLLECTION_NAMES.PlayerCollection.value);
},
onBeforeAction: function(){
Session.set('active_menu_option','home');
this.next();
},
onAfterAction: function(){
},
data: function(){
return {active_menu_option: {'home':'active'}};
},
yieldTemplates: {
'jumbotronTemplate': {
to: 'jumbotron'
}
}
});
});


Is it kosher to call/use the Session variable in this setting? I seem to be getting wonky/non-deterministic behavior.


Aucun commentaire:

Enregistrer un commentaire