diff --git a/anatomy/static/js/anatomy.js b/anatomy/static/js/anatomy.js index 2cbc5aa9..1a428591 100644 --- a/anatomy/static/js/anatomy.js +++ b/anatomy/static/js/anatomy.js @@ -480,4 +480,37 @@ function create_popup_window(url, title) { return false; } -window.create_popup_window = create_popup_window \ No newline at end of file +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]'); + }) + } + +} \ No newline at end of file diff --git a/anatomy/templates/anatomy/user_answer_question_view.html b/anatomy/templates/anatomy/user_answer_question_view.html index c501688b..f3a13905 100644 --- a/anatomy/templates/anatomy/user_answer_question_view.html +++ b/anatomy/templates/anatomy/user_answer_question_view.html @@ -21,11 +21,6 @@ {% block js %} {% endblock %} \ No newline at end of file diff --git a/rapids/templates/rapids/user_answer_question_view.html b/rapids/templates/rapids/user_answer_question_view.html index 7e0423ac..2221e37e 100644 --- a/rapids/templates/rapids/user_answer_question_view.html +++ b/rapids/templates/rapids/user_answer_question_view.html @@ -21,11 +21,6 @@ {% block js %}