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
57c83b0d
Commit
57c83b0d
authored
Dec 31, 2011
by
Aaron Boushley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove tight coupling of the model to the view.
parent
0774dd53
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
9 deletions
+3
-9
todo-example/backbone_require/js/models/todo.js
todo-example/backbone_require/js/models/todo.js
+1
-2
todo-example/backbone_require/js/views/todos.js
todo-example/backbone_require/js/views/todos.js
+2
-7
No files found.
todo-example/backbone_require/js/models/todo.js
View file @
57c83b0d
...
...
@@ -19,10 +19,9 @@ define(['underscore', 'backbone'], function(_, Backbone) {
this
.
save
({
done
:
!
this
.
get
(
"
done
"
)});
},
// Remove this Todo from *localStorage*
and delete its view
.
// Remove this Todo from *localStorage*.
clear
:
function
()
{
this
.
destroy
();
this
.
view
.
remove
();
}
});
...
...
todo-example/backbone_require/js/views/todos.js
View file @
57c83b0d
...
...
@@ -24,9 +24,9 @@ define([
// a one-to-one correspondence between a **Todo** and a **TodoView** in this
// app, we set a direct reference on the model for convenience.
initialize
:
function
()
{
_
.
bindAll
(
this
,
'
render
'
,
'
close
'
);
_
.
bindAll
(
this
,
'
render
'
,
'
close
'
,
'
remove
'
);
this
.
model
.
bind
(
'
change
'
,
this
.
render
);
this
.
model
.
view
=
this
;
this
.
model
.
bind
(
'
destroy
'
,
this
.
remove
)
;
},
// Re-render the contents of the todo item.
...
...
@@ -68,11 +68,6 @@ define([
if
(
e
.
keyCode
==
13
)
this
.
close
();
},
// Remove this view from the DOM.
remove
:
function
()
{
$
(
this
.
el
).
remove
();
},
// Remove the item, destroy the model.
clear
:
function
()
{
this
.
model
.
clear
();
...
...
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