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
Sven Franck
todomvc
Commits
6030db61
Commit
6030db61
authored
Oct 31, 2013
by
Sindre Sorhus
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #708 from kamilogorek/knockout-trimming
Knockout input value trimming on edit
parents
bcd7682d
084b0664
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
architecture-examples/knockoutjs/js/app.js
architecture-examples/knockoutjs/js/app.js
+11
-1
labs/dependency-examples/knockoutjs_require/js/viewmodels/todo.js
...endency-examples/knockoutjs_require/js/viewmodels/todo.js
+11
-1
No files found.
architecture-examples/knockoutjs/js/app.js
View file @
6030db61
...
...
@@ -111,7 +111,17 @@
self
.
stopEditing
=
function
(
item
)
{
item
.
editing
(
false
);
if
(
!
item
.
title
().
trim
())
{
var
title
=
item
.
title
();
var
trimmedTitle
=
title
.
trim
();
// Observable value changes are not triggered if they're consisting of whitespaces only
// Therefore we've to compare untrimmed version with a trimmed one to chech whether anything changed
// And if yes, we've to set the new value manually
if
(
title
!==
trimmedTitle
)
{
item
.
title
(
trimmedTitle
);
}
if
(
!
trimmedTitle
)
{
self
.
remove
(
item
);
}
};
...
...
labs/dependency-examples/knockoutjs_require/js/viewmodels/todo.js
View file @
6030db61
...
...
@@ -50,7 +50,17 @@ define([
self
.
stopEditing
=
function
(
item
)
{
item
.
editing
(
false
);
if
(
!
item
.
title
().
trim
())
{
var
title
=
item
.
title
();
var
trimmedTitle
=
title
.
trim
();
// Observable value changes are not triggered if they're consisting of whitespaces only
// Therefore we've to compare untrimmed version with a trimmed one to chech whether anything changed
// And if yes, we've to set the new value manually
if
(
title
!==
trimmedTitle
)
{
item
.
title
(
trimmedTitle
);
}
if
(
!
trimmedTitle
)
{
self
.
remove
(
item
);
}
};
...
...
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