Closed JDittmerCOM closed 2 years ago
I just stumbled onto this as well. My code looks like this:
if (document.getElementsByTagName('select').length >= 1) {
new Choices('select', {
allowHTML: false,
searchEnabled: false,
});
}
Only the first select on the page is working. I'm also not sure what to make of this note in the docs:
Note: If you pass a selector which targets multiple elements, the first matching element will be used. Versions prior to 8.x.x would return multiple Choices instances.
To me it basically sounds like that for each select there should be a new Choices
instance created manually? That would be bad.
Same here.
My solution for the moment
const items = document.querySelectorAll("[data-select]");
items.forEach((item) => new Choices(item));
Thank you for the answers.
However, I found a solution for myself a long time ago.
if($('#choicesjs-gameserver-permissions')[0]){
new Choices('#choicesjs-gameserver-permissions',
{
removeItemButton: true,
searchEnabled: true,
itemSelectText: '',
allowHTML: true
}
);
}
I have two
How can I fix this to be the same as the first field?
Choices.js Version 10.1.0