Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eugene Shen
todomvc
Commits
1d9089af
Commit
1d9089af
authored
Jun 25, 2014
by
Sindre Sorhus
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #929 from dprotti/backbonerequire789
Backbone-require - cancel editing on escape keypress
parents
d910f948
7f17a7b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
dependency-examples/backbone_require/js/common.js
dependency-examples/backbone_require/js/common.js
+2
-1
dependency-examples/backbone_require/js/views/todos.js
dependency-examples/backbone_require/js/views/todos.js
+11
-0
No files found.
dependency-examples/backbone_require/js/common.js
View file @
1d9089af
...
...
@@ -7,6 +7,7 @@ define([], function () {
TodoFilter
:
''
,
// empty, active, completed
// What is the enter key constant?
ENTER_KEY
:
13
ENTER_KEY
:
13
,
ESCAPE_KEY
:
27
};
});
dependency-examples/backbone_require/js/views/todos.js
View file @
1d9089af
...
...
@@ -20,6 +20,7 @@ define([
'
dblclick label
'
:
'
edit
'
,
'
click .destroy
'
:
'
clear
'
,
'
keypress .edit
'
:
'
updateOnEnter
'
,
'
keydown .edit
'
:
'
revertOnEscape
'
,
'
blur .edit
'
:
'
close
'
},
...
...
@@ -93,6 +94,16 @@ define([
}
},
// If you're pressing `escape` we revert your change by simply leaving
// the `editing` state.
revertOnEscape
:
function
(
e
)
{
if
(
e
.
which
===
Common
.
ESCAPE_KEY
)
{
this
.
$el
.
removeClass
(
'
editing
'
);
// Also reset the hidden input back to the original value.
this
.
$input
.
val
(
this
.
model
.
get
(
'
title
'
));
}
},
// Remove the item, destroy the model from *localStorage* and delete its view.
clear
:
function
()
{
this
.
model
.
destroy
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment