Change div+input box to textarea

This commit is contained in:
Abhishek Das
2013-03-25 00:34:30 +05:30
parent edee63c452
commit fc282d0723
5 changed files with 84 additions and 23 deletions
+22
View File
@@ -7,10 +7,32 @@ var app = app || {};
tagName: 'li',
template: $('#taskTemplate').html(),
events: {
'click .task': 'edit',
'blur .edit': 'close',
'keypress .edit': 'add'
},
render: function() {
var tmpl = _.template(this.template);
this.$el.html(tmpl(this.model.toJSON()));
this.$input = this.$('.edit');
return this;
},
edit: function() {
this.$el.addClass('editing');
this.$input.focus();
},
close: function() {
var value = this.$input.val().trim();
this.model.save({content: value});
this.$el.removeClass('editing');
},
add: function() {
this.$input.blur();
}
});