This commit is contained in:
Ross
2021-12-11 22:56:56 +00:00
parent 06af0aed2e
commit 71b8fd9087
6 changed files with 92 additions and 24 deletions
+56
View File
@@ -0,0 +1,56 @@
{% extends 'base.html' %}
{% load render_table from django_tables2 %}
{% block css %}
{% endblock %}
{% block content %}
<div id="view-filter-options">
<h3>Filter CID Users </h3>
<form action="" method="get">
{{ filter.form }}
<input class="btn btn-primary btn-sm mt-1 mb-1" type="submit" />
</form>
</div>
{% render_table table %}
<button id="add-new-cids">Add New</button>
<input type="number" id="add-number" value="number to add">
{% endblock %}
{% block js %}
<script>
$(document).ready(function () {
$("#add-new-cids").click((evt) => {
$.ajax({
url: "{% url 'generic:create_cid_users' %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
number: $("#add-number").get(0).value
},
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('Added');
location.reload();
}
// 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 %}