{% comment %} $(document).ready(function() { $("#{{ form.Completed.id_for_label }}").on("change", function() { var taskId = {{ form.instance.id }}; var completed = $(this).is(":checked"); $.ajax({ url: "/tasks/" + taskId + "/complete/", type: "POST", data: { completed: completed ? "true" : "false", csrfmiddlewaretoken: "{{ csrf_token }}", }, success: function(response) { if (response.success) { // Task completion status updated successfully // Perform additional actions if needed } }, error: function(xhr, status, error) { // Handle the error if needed } }); }); }); {% endcomment %}