File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
03/rendering_content_at_the_clientside/protected Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -41,15 +41,17 @@ var todo = {
41
41
onDelete : function ( e ) {
42
42
e . preventDefault ( ) ;
43
43
44
+ var id = $ ( this ) . parents ( '.task' ) . attr ( 'data-id' ) ;
45
+
44
46
$ . ajax ( {
45
47
url : todo . options . taskEndpoint ,
46
48
type : 'delete' ,
47
49
data : {
48
- id : $ ( this ) . parents ( '.task' ) . attr ( 'data-id' )
50
+ id : id
49
51
} ,
50
52
dataType : 'json' ,
51
- success : function ( response ) {
52
- $ ( '.task[data-id=' + response . data . id + ']' ) . remove ( ) ;
53
+ success : function ( ) {
54
+ $ ( '.task[data-id=' + id + ']' ) . remove ( ) ;
53
55
} ,
54
56
error : todo . onFailure
55
57
} ) ;
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ private function handleDelete($id)
78
78
{
79
79
$ task = $ this ->getTask ($ id );
80
80
if ($ task ->delete ()) {
81
- $ this ->sendResponse ($ task -> attributes );
81
+ $ this ->sendResponse (' OK ' );
82
82
}
83
83
else {
84
84
$ this ->sendResponse (array (), 500 , array ('Unable to delete task. ' ));
You can’t perform that action at this time.
0 commit comments