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
958622a9
Commit
958622a9
authored
Dec 22, 2013
by
Sindre Sorhus
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #756 from kamilogorek/backbone-elements-caching
Backbone list DOM element cached Fixes #682
parents
cadd3294
3c1f3855
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
architecture-examples/backbone/js/views/app-view.js
architecture-examples/backbone/js/views/app-view.js
+4
-3
No files found.
architecture-examples/backbone/js/views/app-view.js
View file @
958622a9
...
...
@@ -32,6 +32,7 @@ var app = app || {};
this
.
$input
=
this
.
$
(
'
#new-todo
'
);
this
.
$footer
=
this
.
$
(
'
#footer
'
);
this
.
$main
=
this
.
$
(
'
#main
'
);
this
.
$list
=
$
(
'
#todo-list
'
);
this
.
listenTo
(
app
.
todos
,
'
add
'
,
this
.
addOne
);
this
.
listenTo
(
app
.
todos
,
'
reset
'
,
this
.
addAll
);
...
...
@@ -39,7 +40,7 @@ var app = app || {};
this
.
listenTo
(
app
.
todos
,
'
filter
'
,
this
.
filterAll
);
this
.
listenTo
(
app
.
todos
,
'
all
'
,
this
.
render
);
// Suppresses 'add' events with {reset: true} and prevents the app view
// Suppresses 'add' events with {reset: true} and prevents the app view
// from being re-rendered for every model. Only renders when the 'reset'
// event is triggered at the end of the fetch.
app
.
todos
.
fetch
({
reset
:
true
});
...
...
@@ -76,12 +77,12 @@ var app = app || {};
// appending its element to the `<ul>`.
addOne
:
function
(
todo
)
{
var
view
=
new
app
.
TodoView
({
model
:
todo
});
$
(
'
#todo-list
'
)
.
append
(
view
.
render
().
el
);
this
.
$list
.
append
(
view
.
render
().
el
);
},
// Add all items in the **Todos** collection at once.
addAll
:
function
()
{
this
.
$
(
'
#todo-list
'
)
.
html
(
''
);
this
.
$
list
.
html
(
''
);
app
.
todos
.
each
(
this
.
addOne
,
this
);
},
...
...
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