I can see a few problems.
First, the TweetView
has this line:
model:new Tweet(),
Remove that line. It creates a new instance of the Tweet
model, which you don't want to do in the definition of the TweetView
class. (You provide a model instance directly when you create each instance of TweetView
later, in TweetsView.render
.)
Second, in the _.each
block in TweetsView.render
, you have this line:
self.$el.html('');
Move that line before the _.each
loop. That line clears the entire content of TweetsView
, which you don't want to do inside the loop where you're rendering each row.
Third, in that same _.each
block you're creating a new instance of TweetView
and passing it a model
option:
self.$el.append(new TweetView({model:tweet}).render().$el);
Change the value of the model
option from tweet
to i
, which is the model instance for the current iteration of _.each
. (I don't know what tweet
is here; surprised you don't get a syntax error, but maybe it's defined in part of the file that's not shown.)
Finally, also in the _.each
block, move the return this;
line after the close of the _.each
block, so it's the return statement for the render
function itself. (No return
needed in the _.each
block.)
I think that render
function should then look like this:
render:function(){
var self=this;
self.$el.html('');
_.each(this.model.toArray(),function(i){
self.$el.append(new TweetView({model:tweet}).render().$el);
});
return this;
}
See if it works after those changes.