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:
@ -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)
|
||||
});
|
||||
|
Reference in New Issue
Block a user