Slide 40
Slide 40 text
Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com
var Poster = Backbone.View.extend({
tagName: 'form'
, events: {
"change textarea.message": "eChangeBody"
, "keyup textarea.message": "eChangeBody"
}
, initialize: function() {
this.render();
this.setModel(this.model);
}
, setModel: function(model) {
this.model = model;
this.model.on('change:body', _.bind(this.handleUpdateBody, this));
this.handleUpdateBody(this.model, this.model.get('body'));
}
, handleUpdateBody: function(model, body) {
this.$body.val(body).change();
}
, eChangeBody: function(e) {
//Check character counts, identify urls, update model
}
, render: function() {
this.$el.append(this._renderBody());
this.$body = this.$('textarea.message');
return this;
}
}); state management