How To Log A Certain Field Of Every Model In A Collection
Hi im trying to output every 'lat' field from my collection. However anything i do returns the right number of results but they all say undefined, the data is definitely there and
Solution 1:
Ah, so your model attributes
data structure is not what everyone thought. Based on your attributes
structure, you need something like this. It's a bit fragile due to assuming positionHistory is an array with at least one element, but that's where your data is.
var ccLocal = window.router.carsCollection;
_.each(ccLocal.models, function(model) {
console.log(model.get('positionHistory')[0].lat);
})
Post a Comment for "How To Log A Certain Field Of Every Model In A Collection"