-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filtering now refreshes as you type.
- Loading branch information
1 parent
2503d0a
commit 98fa484
Showing
4 changed files
with
55 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const search_form = $("#search_form") | ||
const results_div = $('#results') | ||
const endpoint = '/devices/' | ||
const delay_by_in_ms = 700 | ||
let scheduled_function = false | ||
|
||
let ajax_call = function (endpoint, request_parameters) { | ||
$.getJSON(endpoint, request_parameters) | ||
.done(response => { | ||
// replace the HTML contents | ||
results_div.html(response['html']) | ||
}) | ||
} | ||
|
||
search_form.on('input', function () { | ||
|
||
const request_parameters = { | ||
search_string: $('#id_search_string').val(), | ||
device_role_prod: $('#id_device_role_prod').val(), | ||
authorization_group: $('#id_authorization_group').val() | ||
} | ||
|
||
// if scheduled_function is NOT false, cancel the execution of the function | ||
if (scheduled_function) { | ||
clearTimeout(scheduled_function) | ||
} | ||
|
||
// setTimeout returns the ID of the function to be executed | ||
scheduled_function = setTimeout(ajax_call, delay_by_in_ms, endpoint, request_parameters); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,10 @@ | |
<link rel="icon" href="{% static 'icons/favicon.svg' %}" sizes="any" type="image/svg+xml"> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> | ||
|
||
|
||
<!-- JQuery --> | ||
<script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4=" crossorigin="anonymous"></script> | ||
|
||
|
||
{% block head %}{% endblock %} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters