$(function(){

  $('.tasks li input[type=checkbox]').on('change', function(e){
    var $this = $(this);
    var li = $this.closest('li');
    var url = $this.closest('form').attr('action');
    var completed = $this.is(':checked');

    // Do the work
    $.ajax({
        type: "put",
        url: url,
        data: {
          completed: completed
        }
    })
    .done(function(resp){
        if (resp.result) {
            if (resp.task.completed) li.addClass('complete');
            else li.removeClass('complete');
        }
    });
  });

});
@@ -230,27 +230,8 @@
 );%0A%0A
-    // Do the work%0A
     
@@ -493,32 +493,237 @@
 ass('complete');
+%0A%0A            count = li.closest('ul').find('li:not(.complete)').length%0A            li.closest('.tasks').find('h4').html(%0A                count + %22 Incomplete Task%22 + (count == 1 ? %22%22 : %22s%22)%0A            );
 %0A        %7D%0A    %7D

update the number of incomplete tasks on change