Skip to content

Commit

Permalink
Specify channel/model on instantiation -- simpler pattern.
Browse files Browse the repository at this point in the history
  • Loading branch information
akavlie committed Jan 7, 2012
1 parent 6d94f43 commit 497abf2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions assets/js/collections.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
var Stream = Backbone.Collection.extend({ var Stream = Backbone.Collection.extend({
model: Message, model: Message,


initialize: function(parent_ref) { initialize: function() {
this.channel = parent_ref;
this.bind('add', irc.appView.addMessage); this.bind('add', irc.appView.addMessage);
} }
}); });
Expand Down
4 changes: 2 additions & 2 deletions assets/js/models.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ var ChatWindow = Backbone.Model.extend({


initialize: function() { initialize: function() {
console.log('chat window created'); console.log('chat window created');
this.stream = new Stream(this); this.stream = new Stream({channel: this});
this.view = new ChatView; this.view = new ChatView({model: this});
}, },


part: function() { part: function() {
Expand Down
3 changes: 1 addition & 2 deletions assets/js/views/chat.js
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,5 @@
var ChatView = Backbone.View.extend({ var ChatView = Backbone.View.extend({
initialize: function(modelRef) { initialize: function() {
this.model = modelRef;
this.el = ich.chat(); this.el = ich.chat();
this.render(); this.render();
}, },
Expand Down

0 comments on commit 497abf2

Please sign in to comment.