Commit b4c0008f authored by Sindre Sorhus's avatar Sindre Sorhus

Merge pull request #933 from dprotti/backbonemarionetterequire789

backbone-marionette-require: cancel editing on escape keypress
parents 56cd282f 8bccbe70
...@@ -24,7 +24,7 @@ define([ ...@@ -24,7 +24,7 @@ define([
'click .toggle': 'toggle', 'click .toggle': 'toggle',
'click .destroy': 'destroy', 'click .destroy': 'destroy',
'dblclick label': 'onEditDblclick', 'dblclick label': 'onEditDblclick',
'keypress .edit': 'onEditKeypress', 'keydown .edit': 'onEditKeyDown',
'blur .edit': 'onEditBlur' 'blur .edit': 'onEditBlur'
}, },
...@@ -58,13 +58,14 @@ define([ ...@@ -58,13 +58,14 @@ define([
this.ui.edit.focus().val(this.value); this.ui.edit.focus().val(this.value);
}, },
onEditKeypress: function (event) { onEditKeyDown: function (event) {
if (event.which === ENTER_KEY) { if (event.which === ENTER_KEY) {
this.ui.edit.trigger('blur'); this.ui.edit.trigger('blur');
} }
if (event.which === ESCAPE_KEY) { if (event.which === ESCAPE_KEY) {
this.toggleEditingMode(); this.ui.edit.val(this.model.get('title'));
this.ui.edit.trigger('blur');
} }
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment