I use choices in single-select mode and set placeholder: true, placeholderValue: 'a string'. The placeholder is not displayed in UI if there are no choices. When I add choices later, the placeholder is displayed correctly.
This happens with version 7.0.0
I came across this problem since choices.ClearStore() also removes the placeholder item. The solution I'm using is this:
placeholderItem = choices._getTemplate(
'placeholder',
'This is a placeholder'
);
choices.itemList.append(placeholderItem);
Where 'choices' is the name of your choices object.
Possibly same issue.... Using clearChoices. Getting a javascript error intermittently on line 2630 placeholderItem.innerHTML = this._placeholderValue || '';
if (this._isSelectOneElement) {
placeholderItem.innerHTML = this._placeholderValue || '';
} else {
this.input.placeholder = this._placeholderValue || '';
}
Thanks for contributing to this issue. As it has been 60 days since the last activity, this issue is being automatically closed. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please do feel free to either reopen this issue or open a new one. We'll gladly take a look again!
@jshjohnson I have the same problem. Is there any update yet?
Hi @jshjohnson I am having this issue now. I am fetching items with async ajax and one of the elements returned has the property selected set to true. Is there a fix or workaround for this? Thanks!
@hg64 @Colin-Moran @code-chris pinging you guys too in case you have found a proper solution for this.
Most helpful comment
I came across this problem since choices.ClearStore() also removes the placeholder item. The solution I'm using is this:
placeholderItem = choices._getTemplate( 'placeholder', 'This is a placeholder' ); choices.itemList.append(placeholderItem);Where 'choices' is the name of your choices object.