This commit is contained in:
Ross
2021-08-03 22:00:56 +01:00
parent 0f502a1ed2
commit 3d96cad503
4 changed files with 51 additions and 1 deletions
@@ -2,7 +2,7 @@
{% extends 'rapids/base.html' %}
{% block content %}
User answer: {{ciduseranswer.cid}}
CID: {{ciduseranswer.cid}}
<h3>Question</h3>
{{ciduseranswer.question}}
+38
View File
@@ -13,6 +13,44 @@
<input class="btn btn-primary btn-sm mt-1 mb-1" type="submit" />
</form>
</div>
<button id="delete-all-button">Delete all</button>
{% render_table table %}
{% endblock %}
{% block js %}
<script>
$(document).ready(function () {
//$("thead input:checked").each((n, el) => {
answer_ids = [];
$("tbody input:checked").each((n, el) => {
answer_ids.push(el.value);
})
$("#delete-all-button").on("click", function () {
$.ajax({
url: "{% url 'longs:user_answer_delete_multiple' %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
answer_ids: 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('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]');
})
})
});
</script>
{% endblock %}