|
new autoComplete({ |
|
data: { |
|
src: films, |
|
}, |
|
selector: "#autoComplete", |
|
threshold: 2, |
|
debounce: 100, |
|
searchEngine: "strict", |
|
resultsList: { |
|
render: true, |
|
container: source => { |
|
source.setAttribute("id", "food_list"); |
|
}, |
|
destination: document.querySelector("#autoComplete"), |
|
position: "afterend", |
|
element: "ul" |
|
}, |
|
maxResults: 5, |
|
highlight: true, |
|
resultItem: { |
|
content: (data, source) => { |
|
source.innerHTML = data.match; |
|
}, |
|
element: "li" |
|
}, |
|
noResults: () => { |
|
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 => { |
|
document.getElementById('autoComplete').value = feedback.selection.value; |
|
} |
|
}); |