mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-06-27 16:00:04 +08:00
Change div+input box to textarea
This commit is contained in:
@@ -8,6 +8,8 @@ var app = app || {};
|
||||
parent_id: '',
|
||||
content: ''
|
||||
},
|
||||
|
||||
url: '/task'
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user