Closed dennismonsewicz closed 10 years ago
Here are my routes:
Meteor.Router.add({ '/jobs/:page': function(page) { Session.set('page', page) return 'jobs'; }, '/industry/:name': { to: 'jobs', and: function(name) { Session.set('currentIndustry', name); } } });
I am needing the Session of currentIndustry to filter my jobs array on the front-end
Template[templateName].helpers({ selected: function(){ return Session.get('perPage'); }, jobs: function() { var cursor, options = {}; if(Session.get('currentIndustry')) { options.industry = Session.get('currentIndustry'); } logger(Session.get('currentIndustry')); if(Session.get('currentMapArea')) { city = Cities.findOne(Session.get('currentMapArea')); address = city.city.toProperCase() + ", " + city.state; options.address = address; } return Pagination.collection( Jobs, options, {sort: { dateacquired: -1 }}, {perPage: Session.get('perPage') || 10, currentPage: Session.get('page') || 1} ); } });
If I console.log(Session.get('currentIndustry')) in my jobs helper, it returns null
console.log(Session.get('currentIndustry'))
Does the and function run?
and
Yes, it runs and returns the passed in :name
:name
@tmeasday I figured it out... I was setting the Session variable to null in a Meteor.startup function
Here are my routes:
I am needing the Session of currentIndustry to filter my jobs array on the front-end
If I
console.log(Session.get('currentIndustry'))
in my jobs helper, it returns null