I have a code where when a checkbox is checked, the list item that the checkbox is contained in is supposed to fade out from view. Here is my current code:
$(document).on('change', '.task', function(){
var id = $(this).attr('id');
$.ajax({
url: '/task/'+id,
method: 'POST',
data: {'_method' : 'PUT'},
dataType: 'json',
success:function(json){
if(json.isSent){
alert('Task Updated Successfully!');
$(this).closest('li').fadeOut(500);
}
}
});
}
And here is my html (Note: I am using Laravel, so some of the html contains Blade code, but it does work properly)'
@foreach ($return['Tasks'] as $task)
<li class="list-group-item">
<div class="form-group">
<label class="control-label">{{ $task->name }} (Due on {{ $task->timeDue->format('l\\, F jS \\a\\t h:i:s A') }})</label>
<div class="float-left">
<input type="checkbox" id="{{ $task->id }}" class="big-checkbox task" />
</div>
</div>
</li>
@endforeach
When I check the checkbox, the "Task Updated Successfully" alert shows up, so I know that the code is running, but the fadeOut won't do anything. There are no errors in the console either to tell me what went wrong, it just won't fade out.