I'm logging one of my Backbone collections, and I'm getting this output. In the object summary why does it say that the length
is 0 and the models
array is empty, but in the dropdown detail, gives the correct length
and model
array? Also when I run console.log(this.collection.models)
it returns an empty array just like in the summary.
Asked
Active
Viewed 57 times
0

user2066880
- 4,825
- 9
- 38
- 64
-
2Probably something like http://stackoverflow.com/a/11463190/1071630 – nikoshr Aug 29 '13 at 09:48
1 Answers
1
It might be a race condition since fetch is an asynchronous method.
Have you confirmed fetch has processed the request from the server before you call this.model.itemList
?
To confirm this, add a console log message in the fetch method
user.fetch({
success: function(response){
user.itemlist = new itemlistcollection(response.items)
console.log(user.itemList)
}
});

Vaibs_Cool
- 6,126
- 5
- 28
- 61