File tree Expand file tree Collapse file tree 2 files changed +9
-15
lines changed Expand file tree Collapse file tree 2 files changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -10,20 +10,6 @@ $(function () {
10
10
title : text
11
11
} ) ;
12
12
var item = new TodoItemView ( { model} ) ;
13
- //var $li = $('<li>');
14
- //var $text = $('<span>').addClass('todoText').text(text);
15
- //var $checkbox = $('<input type="checkbox">');
16
- //var $remove = $('<i>').addClass('removeBtn fa fa-times');
17
- //$remove.on('click', function () {
18
- // if (!window.confirm('消しますよ')) {
19
- // return;
20
- // }
21
- // $li.remove();
22
- //});
23
- //$checkbox.on('click', function () {
24
- // $li.toggleClass('is-complete');
25
- //});
26
- //$li.append($checkbox, $text, $remove);
27
13
return item . render ( ) . el ;
28
14
}
29
15
Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ class TodoItemView extends View {
18
18
'click .removeBtn' : 'removeItem'
19
19
} ;
20
20
super ( options ) ;
21
+
22
+
23
+ this . listenTo ( this . model , 'destroy' , this . remove ) ;
21
24
}
22
25
23
26
// *Re-render the contents of the todo item.*
@@ -28,10 +31,15 @@ class TodoItemView extends View {
28
31
}
29
32
30
33
toggleComplete ( ) {
31
-
34
+ this . model . toggle ( ) ;
32
35
}
33
36
34
37
removeItem ( ) {
38
+ if ( ! window . confirm ( '消しますよ' ) ) {
39
+ return ;
40
+ }
41
+ this . model . destroy ( ) ;
42
+ return this ;
35
43
}
36
44
}
37
45
export default TodoItemView ;
You can’t perform that action at this time.
0 commit comments