File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -8,5 +8,11 @@ class TodoItem extends Model {
8
8
completed : false
9
9
} ;
10
10
}
11
+
12
+ toggle ( ) {
13
+ this . save ( {
14
+ completed : ! this . get ( 'completed' )
15
+ } ) ;
16
+ }
11
17
}
12
18
export default TodoItem ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ class TodoItemView extends View {
7
7
this . tagName = 'li' ;
8
8
// *Cache the template function for a single item.*
9
9
this . template = _ . template ( `
10
- <input type="checkbox">
10
+ <input type="checkbox" class="<%= completed ? 'is-complete' : '' %>" <%= completed ? 'checked' : '' %> >
11
11
<span class="todoText"><%- title %></span>
12
12
<i class="removeBtn fa fa-times"></i>
13
13
` ) ;
@@ -19,7 +19,7 @@ class TodoItemView extends View {
19
19
} ;
20
20
super ( options ) ;
21
21
22
-
22
+ this . listenTo ( this . model , 'change' , this . render ) ;
23
23
this . listenTo ( this . model , 'destroy' , this . remove ) ;
24
24
}
25
25
You can’t perform that action at this time.
0 commit comments