Created
January 7, 2014 23:53
-
-
Save jaredtmartin/8309126 to your computer and use it in GitHub Desktop.
Grouping Breaks Reactivity
This file contains 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 | |
Deps.autorun(function(){ | |
Assignments.grouped = {}; | |
var raw_list = Assignments.find().fetch(); | |
for (var i = raw_list.length - 1; i >= 0; i--) { | |
if (Assignments.grouped[raw_list[i].date] == undefined) {Assignments.grouped[raw_list[i].date]={}}; | |
if (Assignments.grouped[raw_list[i].date][raw_list[i].meetingId] == undefined) {Assignments.grouped[raw_list[i].date][raw_list[i].meetingId]=[]}; | |
Assignments.grouped[raw_list[i].date][raw_list[i].meetingId].push(raw_list[i]); | |
}; | |
}); | |
// 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