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
81d044dc
Commit
81d044dc
authored
Jun 29, 2014
by
Sindre Sorhus
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #935 from pgilad/patch-2
Cache $todoList and improve readability
parents
33513d75
1655470b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
dependency-examples/backbone_require/js/views/app.js
dependency-examples/backbone_require/js/views/app.js
+4
-3
No files found.
dependency-examples/backbone_require/js/views/app.js
View file @
81d044dc
...
@@ -35,6 +35,7 @@ define([
...
@@ -35,6 +35,7 @@ define([
this
.
$input
=
this
.
$
(
'
#new-todo
'
);
this
.
$input
=
this
.
$
(
'
#new-todo
'
);
this
.
$footer
=
this
.
$
(
'
#footer
'
);
this
.
$footer
=
this
.
$
(
'
#footer
'
);
this
.
$main
=
this
.
$
(
'
#main
'
);
this
.
$main
=
this
.
$
(
'
#main
'
);
this
.
$todoList
=
this
.
$
(
'
#todo-list
'
);
this
.
listenTo
(
Todos
,
'
add
'
,
this
.
addOne
);
this
.
listenTo
(
Todos
,
'
add
'
,
this
.
addOne
);
this
.
listenTo
(
Todos
,
'
reset
'
,
this
.
addAll
);
this
.
listenTo
(
Todos
,
'
reset
'
,
this
.
addAll
);
...
@@ -76,12 +77,12 @@ define([
...
@@ -76,12 +77,12 @@ define([
// appending its element to the `<ul>`.
// appending its element to the `<ul>`.
addOne
:
function
(
todo
)
{
addOne
:
function
(
todo
)
{
var
view
=
new
TodoView
({
model
:
todo
});
var
view
=
new
TodoView
({
model
:
todo
});
$
(
'
#todo-list
'
)
.
append
(
view
.
render
().
el
);
this
.
$todoList
.
append
(
view
.
render
().
el
);
},
},
// Add all items in the **Todos** collection at once.
// Add all items in the **Todos** collection at once.
addAll
:
function
()
{
addAll
:
function
()
{
this
.
$
(
'
#todo-list
'
).
html
(
''
);
this
.
$
todoList
.
empty
(
);
Todos
.
each
(
this
.
addOne
,
this
);
Todos
.
each
(
this
.
addOne
,
this
);
},
},
...
@@ -124,7 +125,7 @@ define([
...
@@ -124,7 +125,7 @@ define([
Todos
.
each
(
function
(
todo
)
{
Todos
.
each
(
function
(
todo
)
{
todo
.
save
({
todo
.
save
({
'
completed
'
:
completed
completed
:
completed
});
});
});
});
}
}
...
...
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