-
-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Element added in resultsList.container is removed on second input #206
Comments
For example a new property on Would probably need to have config for if to add them when results are 0. Would be nice to have that information in |
Thank you it works great! 👍 I changed my code to also make sure clicking the node doesn't close the list like this container: element => {
const result = document.createElement("p")
result.setAttribute("class", "no_result")
result.setAttribute("tabindex", "1")
result.innerHTML = `Skriv inn hele organisasjonsnummeret, uten mellomrom.`
result.addEventListener("click", (ev) => { ev.stopPropagation() } )
element.appendChild(result)
}, |
Glad to hear that! :)
Since the |
Can you explain how? Because you invoke I think I am misunderstanding something. |
Wait you just changed it :-D |
You're right I've just noticed that after my reply and I've just changed it in v9.0.5 Check it and let me know :) |
Yes, my bad 😅 |
Great work thanks again! 💯 👍 resultsList: {
container: element => {
if (element.children.length === 1 && element.children[0].classList.contains("autoComplete_ingen-resultat")) {
return
}
const result = document.createElement("p")
result.setAttribute("class", "autoComplete_info")
result.setAttribute("tabindex", "-1")
result.innerHTML = `<span class="iconify-inline" data-icon="fa-solid:exclamation-triangle"></span>Du må velge en bedrift fra denne listen. Det er ikke nok å skrive inn navnet eller organisasjonsnummeret.`
result.addEventListener("click", ev => {
ev.stopPropagation()
})
element.prepend(result)
},
maxResults: 8,
idName: "bedrift-liste",
noResults: (list, query) => {
const result = document.createElement("li")
result.setAttribute("class", "autoComplete_ingen-resultat")
let nr = /^\d+$/.test(query)
if (nr === true) {
result.innerHTML = `<span class="iconify-inline" data-icon="fa-solid:exclamation-triangle"></span>Skriv inn hele organisasjonsnummeret, uten mellomrom.`
} else {
result.innerHTML = `<span class="iconify-inline" data-icon="fa-solid:exclamation-triangle"></span>Fant ingen resultat for "${query}".`
}
list.appendChild(result)
}
}, |
System Information
Describe the bug
Here's the code for one of my autocompletes (work in progress)
In
resultsList.container
I add ap
element at the top of the list that I want to use to give helpful information to the user. Here's a screenshot:(the text in the
p
is currently wrong, also the element is not styled properly - I just started implementing it, but that's not relevant to the bug)Steps to reproduce the behavior: <!-- Example below-!>
resultsList.container
I want the element to be there every time :-)
I think the "problem" is in your function
generateList
you dolist.innerHTML = "";
iflist
is non-null.Perhaps it would be possible to add an attribute to my element that makes autoComplete.js not nuke it?
Or maybe you have an alternative solution for me :-)
Thank you!
The text was updated successfully, but these errors were encountered: