This commit is contained in:
Ross
2021-09-29 22:29:02 +01:00
parent 8916d9b0ff
commit e400f8a509
3 changed files with 12 additions and 102 deletions
@@ -21,40 +21,10 @@
{% block js %}
<script>
$(document).ready(function () {
$("#delete-selected-button").on("click", function () {
answer_ids = [];
$("tbody input:checked").each((n, el) => {
answer_ids.push(el.value);
})
if (confirm(`Delete ${answer_ids.length} answers?`)) {
$.ajax({
url: "{% url 'anatomy:user_answer_delete_multiple' %}",
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.')
location.reload();
} else {
toastr.info('Error deleting questions.')
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
})
.always(function () {
console.log('[Done]');
})
}
$("#delete-selected-button").on("click", () => {
window.delete_multiple(
"{% url 'anatomy:user_answer_delete_multiple' %}", "{{ csrf_token }}"
)
})
});
</script>
@@ -21,40 +21,10 @@
{% block js %}
<script>
$(document).ready(function () {
$("#delete-selected-button").on("click", function () {
answer_ids = [];
$("tbody input:checked").each((n, el) => {
answer_ids.push(el.value);
})
if (confirm(`Delete ${answer_ids.length} answers?`)) {
$.ajax({
url: "{% url 'rapids:user_answer_delete_multiple' %}",
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.')
location.reload();
} else {
toastr.info('Error deleting questions.')
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
})
.always(function () {
console.log('[Done]');
})
}
$("#delete-selected-button").on("click", () => {
window.delete_multiple(
"{% url 'rapids:user_answer_delete_multiple' %}", "{{ csrf_token }}"
)
})
});
</script>
@@ -21,40 +21,10 @@
{% block js %}
<script>
$(document).ready(function () {
$("#delete-selected-button").on("click", function () {
answer_ids = [];
$("tbody input:checked").each((n, el) => {
answer_ids.push(el.value);
})
if (confirm(`Delete ${answer_ids.length} answers?`)) {
$.ajax({
url: "{% url 'sbas:user_answer_delete_multiple' %}",
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.')
location.reload();
} else {
toastr.info('Error deleting questions.')
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
})
.always(function () {
console.log('[Done]');
})
}
$("#delete-selected-button").on("click", () => {
window.delete_multiple(
"{% url 'sbas:user_answer_delete_multiple' %}", "{{ csrf_token }}"
)
})
});
</script>