1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-25 19:47:23 +02:00

🎨 Better autocomplete field

This commit is contained in:
Yohann D'ANELLO
2020-08-06 18:27:57 +02:00
parent 5b3361f086
commit d95cd8c7c7
3 changed files with 9 additions and 3 deletions

View File

@ -10,6 +10,8 @@ $(document).ready(function () {
if (!name_field)
name_field = "name";
let input = target.val();
target.addClass("is-invalid");
target.removeClass("is-valid");
$("#" + prefix + "_reset").removeClass("d-none");
$.getJSON(api_url + (api_url.includes("?") ? "&" : "?") + "format=json&search=^" + input + api_url_suffix, function(objects) {
@ -27,6 +29,10 @@ $(document).ready(function () {
target.val(obj[name_field]);
$("#" + prefix + "_pk").val(obj.id);
results_list.html("");
target.removeClass("is-invalid");
target.addClass("is-valid");
if (typeof autocompleted != 'undefined')
autocompleted(obj, prefix)
});