.
This commit is contained in:
@@ -481,3 +481,36 @@ function create_popup_window(url, title) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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]');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,11 +21,6 @@
|
|||||||
{% block js %}
|
{% block js %}
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("table thead th input").click((e) => {
|
|
||||||
let status = e.currentTarget.checked; console.log(status, $("table tbody input")); $("table tbody input").prop("checked", status);
|
|
||||||
})
|
|
||||||
//$("thead input:checked").each((n, el) => {
|
|
||||||
|
|
||||||
$("#delete-selected-button").on("click", function () {
|
$("#delete-selected-button").on("click", function () {
|
||||||
answer_ids = [];
|
answer_ids = [];
|
||||||
$("tbody input:checked").each((n, el) => {
|
$("tbody input:checked").each((n, el) => {
|
||||||
|
|||||||
@@ -21,38 +21,9 @@
|
|||||||
{% block js %}
|
{% block js %}
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
//$("thead input:checked").each((n, el) => {
|
$("#delete-selected-button").on("click", window.delete_multiple(
|
||||||
|
"{% url 'longs:user_answer_delete_multiple' %}", "{{ csrf_token }}"
|
||||||
$("#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 'longs: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.')
|
|
||||||
}
|
|
||||||
// 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>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -21,11 +21,6 @@
|
|||||||
{% block js %}
|
{% block js %}
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("table thead th input").click((e) => {
|
|
||||||
let status = e.currentTarget.checked; console.log(status, $("table tbody input")); $("table tbody input").prop("checked", status);
|
|
||||||
})
|
|
||||||
//$("thead input:checked").each((n, el) => {
|
|
||||||
|
|
||||||
$("#delete-selected-button").on("click", function () {
|
$("#delete-selected-button").on("click", function () {
|
||||||
answer_ids = [];
|
answer_ids = [];
|
||||||
$("tbody input:checked").each((n, el) => {
|
$("tbody input:checked").each((n, el) => {
|
||||||
|
|||||||
@@ -21,11 +21,6 @@
|
|||||||
{% block js %}
|
{% block js %}
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("table thead th input").click((e) => {
|
|
||||||
let status = e.currentTarget.checked; console.log(status, $("table tbody input")); $("table tbody input").prop("checked", status);
|
|
||||||
})
|
|
||||||
//$("thead input:checked").each((n, el) => {
|
|
||||||
|
|
||||||
$("#delete-selected-button").on("click", function () {
|
$("#delete-selected-button").on("click", function () {
|
||||||
answer_ids = [];
|
answer_ids = [];
|
||||||
$("tbody input:checked").each((n, el) => {
|
$("tbody input:checked").each((n, el) => {
|
||||||
|
|||||||
@@ -481,3 +481,36 @@ function create_popup_window(url, title) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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