I am very new to backbone and I am trying to troubleshoot an error in someones code. The problem is that I have a collection that I cant seem to iterate over. If I put a break point prior to the each loop, I can see that the collection exists but the loop will still not iterate over it. Here is the code that I have. Again, I am new to backbone, so if there is any qualifying information you need, please let me know:
var ReportsListView = ActivityDBView.extend({
render: function() {
this.collection.each(function(report) {
console.log(report.get('canEdit'));
console.log(report.get('programSpecific'));
}, this);
},
drawReportList: function(reports, title, includeEditLinks) {
});
But, if I add this before render:
initialize: function() {
},
It will sometimes work. When it does work, I can iterate over the list but all the gets return undefined. I don't know why I cannot iterate over the list or why the code behavior is inconsistent. Could this be due to the Async nature or that there is some kind of race?
Any help would be great.