Created
January 7, 2014 23:49
-
-
Save jaredtmartin/8309085 to your computer and use it in GitHub Desktop.
Grouping Broke Reactivity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// collections/assignments.js | |
Assignments.group_assignments = function(){ | |
console.log('Grouping Assignments'); | |
var grouped = {}; | |
var raw_list = Assignments.find().fetch(); | |
for (var i = raw_list.length - 1; i >= 0; i--) { | |
if (grouped[raw_list[i].date] == undefined) {grouped[raw_list[i].date]={}}; | |
if (grouped[raw_list[i].date][raw_list[i].meetingId] == undefined) {grouped[raw_list[i].date][raw_list[i].meetingId]=[]}; | |
grouped[raw_list[i].date][raw_list[i].meetingId].push(raw_list[i]); | |
}; | |
return grouped; | |
} | |
Deps.autorun(function(){ | |
Assignments.grouped = Assignments.group_assignments(); | |
}); | |
// views/assignments.js | |
Template.assignments.helpers({ | |
meetings: function(){ | |
return Assignments.grouped[Session.get('current_date')]; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment