var Chat = Backbone.Model.extend({
messageList: new MessageList(),
messageListView: new MessageListView({collection: this.messageList}),
switchChannel: function(channel) {
this.messageList.fetch({url: 'channels/'+channel, reset: true})
}
});
// in other file
var MessageList = Backbone.Collection.extend({
model: Message,
})
var MessageListView = Backbone.View.extend({
initialize: function(){
console.log(this.collection)
this.listenTo(this.collection, 'reset', this.render);
},
console.log(this.collection)
-> undefined