backbone.js - Can't loop over backbone collection -
it seems can't loop through backbone collection. i've seen topic in several threads, none of solutions help.
render:function () { this.$el.html(this.template(this.model.attributes)); var = this; console.log(this.projects.models); _.each(this.projects.models, function(model) { console.log(model); }); return this; }
from console shows array[2] expect see each model well. know i'm doing wrong here ?
to collection content array, use method tojson
(e.g.: collection.tojson()
)
next, loop on entire collection, use each
method on collection instances!
collection.each(function( model ) { console.log(model) });
if don't show full collection, problem in how add items inside collection, not in looping logic.
Comments
Post a Comment