Based on the result you provided, it does not look as if any “model” was printed. This is probably due to the fact that when the .each() block is .each() , this.collection may not have been fully selected yet. This is due to the asynchronous nature of JavaScript.
Try this in your initialization method:
initialize: function() { var me = this; this.collection = new UserCollection(); // Listen to 'reset' events from collection, so when .fetch() is completed and all // ready to go, it'll trigger .render() automatically. this.listenTo(this.collection, 'reset', this.render); this.collection.fetch(); },
Another way to handle this is to add a success handler on extraction, but I think that when listening for events, reset should be enough.
Hope this helps!
By the way, as Cyclone says, the handler for .each should just be a model without an index. :)
Dashk
source share