511b121a2f
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.
23 lines
593 B
JavaScript
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();
|
|
},
|
|
});
|
|
})();
|