Inside Meteor, I wish to change the order of a collection that is rendered inside a loop dynamically:
Template.chartPage.helpers({
employee:function(){
sortArr = [];
var timePeriod = Session.get("period");
var currentPage = Session.get("current_page");
sortArr[currentPage+'.'+timePeriod] = "asc";
return EmployeeCollection.find({}, sortArr).fetch();
},
});
HTML:
{{#each employee}}
{{first_name}}
{{/each}}
I want it so that when the session variable for period
and current_page
change, so does the sort order in the helper - the session variables do get updated, but the template isn't rerendered into a sort.