.
This commit is contained in:
+34
-1
@@ -480,4 +480,37 @@ function create_popup_window(url, title) {
|
||||
return false;
|
||||
}
|
||||
|
||||
window.create_popup_window = create_popup_window
|
||||
window.create_popup_window = create_popup_window
|
||||
|
||||
window.delete_multiple(url, csrf_token) {
|
||||
|
||||
answer_ids = [];
|
||||
$("tbody input:checked").each((n, el) => {
|
||||
answer_ids.push(el.value);
|
||||
})
|
||||
if (confirm(`Delete ${answer_ids.length} answers?`)) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: {
|
||||
csrfmiddlewaretoken: csrf_token,
|
||||
answer_ids: JSON.stringify(answer_ids) // 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('Deleted.')
|
||||
}
|
||||
// show some message according to the response.
|
||||
// For eg. A message box showing that the status has been changed
|
||||
})
|
||||
.always(function () {
|
||||
console.log('[Done]');
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user