.
This commit is contained in:
@@ -58,6 +58,34 @@
|
||||
console.log('[Done]');
|
||||
})
|
||||
})
|
||||
$(".exam-archived-switch").on("change", function (evt) {
|
||||
$.ajax({
|
||||
url: evt.currentTarget.dataset.posturl,
|
||||
data: {
|
||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||
archive: this.checked // true if checked else false
|
||||
},
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
})
|
||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||
.done(function (data) {
|
||||
console.log(data);
|
||||
|
||||
if (data.status == "success") {
|
||||
toastr.info(`Exam: ${data.name} [${data.id}]
|
||||
Archived state changed to: ${data.archive}.`)
|
||||
}
|
||||
// show some message according to the response.
|
||||
// For eg. A message box showing that the status has been changed
|
||||
})
|
||||
.fail(function (data) {
|
||||
toastr.error(`Failed to change state`);
|
||||
})
|
||||
.always(function () {
|
||||
console.log('[Done]');
|
||||
})
|
||||
})
|
||||
$("#button-open-access").click(function (evt) {
|
||||
$.ajax({
|
||||
url: evt.currentTarget.dataset.posturl,
|
||||
|
||||
Reference in New Issue
Block a user