Browse files

Specify channel/model on instantiation -- simpler pattern.

  • Loading branch information...
1 parent 6d94f43 commit 497abf2013f35bd4d916f15a2ed26ef8b2bc3fba @akavlie akavlie committed Jan 7, 2012
Showing with 4 additions and 6 deletions.
  1. +1 −2 assets/js/collections.js
  2. +2 −2 assets/js/models.js
  3. +1 −2 assets/js/views/chat.js
View
3 assets/js/collections.js
@@ -2,8 +2,7 @@
var Stream = Backbone.Collection.extend({
model: Message,
- initialize: function(parent_ref) {
- this.channel = parent_ref;
+ initialize: function() {
this.bind('add', irc.appView.addMessage);
}
});
View
4 assets/js/models.js
@@ -93,8 +93,8 @@ var ChatWindow = Backbone.Model.extend({
initialize: function() {
console.log('chat window created');
- this.stream = new Stream(this);
- this.view = new ChatView;
+ this.stream = new Stream({channel: this});
+ this.view = new ChatView({model: this});
},
part: function() {
View
3 assets/js/views/chat.js
@@ -1,6 +1,5 @@
var ChatView = Backbone.View.extend({
- initialize: function(modelRef) {
- this.model = modelRef;
+ initialize: function() {
this.el = ich.chat();
this.render();
},

0 comments on commit 497abf2

Please sign in to comment.