signal-desktop/js/views/conversation_view.js
lilia 511b121a2f 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.
2014-07-27 11:35:49 -10:00

23 lines
593 B
JavaScript

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();
},
});
})();