Skip to content

Commit

Permalink
Merge pull request #347 from seart-group/enhancement/autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
dabico authored Apr 17, 2024
2 parents 21e362b + 943d7f9 commit 9ce870d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion html/js/autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Autocomplete from "https://cdn.jsdelivr.net/npm/[email protected].25/autocomplete.min.js";
import Autocomplete from "https://cdn.jsdelivr.net/npm/[email protected].26/autocomplete.min.js";

(function (base, $, Autocomplete) {
const default_config = {
Expand Down Expand Up @@ -28,6 +28,17 @@ import Autocomplete from "https://cdn.jsdelivr.net/npm/bootstrap5-autocomplete@1
size: 10,
},
onServerResponse: get_response_items,
onServerError: (err, _signal, instance) => {
const $input = $(instance.getInput());
const width = $input.outerWidth();
const $dropdown = $input.next(".dropdown-menu");
if (width) $dropdown.css("width", width);
const span = document.createElement("span");
const $span = $(span).addClass("dropdown-item").addClass("disabled").text("Suggestions not available...");
const li = document.createElement("li");
const $li = $(li).attr("role", "presentation").append($span);
$dropdown.empty().append($li).toggleClass("show");
},
onBeforeFetch: toggle_spinner,
onAfterFetch: toggle_spinner,
};
Expand Down

0 comments on commit 9ce870d

Please sign in to comment.