File size: 1,765 Bytes
1f6053d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
new autoComplete({
data: { // Data src [Array, Function, Async] | (REQUIRED)
src: films,
},
selector: "#autoComplete", // Input field selector | (Optional)
threshold: 2, // Min. Chars length to start Engine | (Optional)
debounce: 100, // Post duration for engine to start | (Optional)
searchEngine: "strict", // Search Engine type/mode | (Optional)
resultsList: { // Rendered results list object | (Optional)
render: true,
container: source => {
source.setAttribute("id", "food_list");
},
destination: document.querySelector("#autoComplete"),
position: "afterend",
element: "ul"
},
maxResults: 5, // Max. number of rendered results | (Optional)
highlight: true, // Highlight matching results | (Optional)
resultItem: { // Rendered result item | (Optional)
content: (data, source) => {
source.innerHTML = data.match;
},
element: "li"
},
noResults: () => { // Action script on noResults | (Optional)
const result = document.createElement("li");
result.setAttribute("class", "no_result");
result.setAttribute("tabindex", "1");
result.innerHTML = "No Results";
document.querySelector("#autoComplete_list").appendChild(result);
},
onSelection: feedback => { // Action script onSelection event | (Optional)
document.getElementById('autoComplete').value = feedback.selection.value;
}
}); |