Refactor conversation view into two classes
One that resides in the left hand column as a list item, and another which displays in the main column and handles ui events therein.pull/749/head
parent
6ff6ef07a9
commit
511b121a2f
@ -0,0 +1,23 @@
|
||||
var Whisper = Whisper || {};
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
Whisper.ConversationView = Backbone.View.extend({
|
||||
initialize: function() {
|
||||
this.listenTo(this.model, 'destroy', this.remove); // auto update
|
||||
var v = new Whisper.MessageListView({collection: this.model.messages()});
|
||||
v.render();
|
||||
},
|
||||
events: {
|
||||
'submit #new-message': 'sendMessage',
|
||||
},
|
||||
|
||||
sendMessage: function(e) {
|
||||
if (!this.$input.val().length) { return false; }
|
||||
this.model.sendMessage(this.$input.val());
|
||||
this.$input.val("");
|
||||
e.preventDefault();
|
||||
},
|
||||
});
|
||||
})();
|
Loading…
Reference in New Issue