-
Notifications
You must be signed in to change notification settings - Fork 617
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
Can we clear the selection in JavaScript? #606
Comments
I also found that the It's a hack, but this is how I did it for now:
If you have multiple instances, make sure that you are more specific with the |
Wait... Are you saying that clearing selected values to have default state of the choices requires above hack? This or destroy + clear selected + init of the whole thing? To reset values? I wish i knew that couple weeks ago... |
For anyone else who stumbles across this thread, you can use the |
Thanks, it works like a charm! |
Hi, I was having problems clearing the select after a submit so, given that I haven't found a concise example on how to use https://jsfiddle.net/pvvnxdementor5/og7yhu4t/42/ I added the clear button, give it an id (a class would work also) and on the function that handles the post success aftermath, I simulate a click to the clear button
So maybe this works for somebody else. I'm not an expert on JS and this library works awesome but I do find it really hard to find instructions on how to call methods after the select choice is created |
Hello. Taking advantage of this issue. Is there any way to unselect some items by passing an array of ids as a argument? |
Hello. |
My problem with this answer is that it also removes the placeholder of a
|
hi, guys do resetting dynamically work at all? all of the options presented or on the documentation does not work at all. ranging from |
I have the same issue when trying to use single select. The way I have found how to solve a problem:
Below the code what I used and have found an issue. HTML Code:
JS Code for testing:
|
Oh, I have found a solution. If you use plugin methods in events then you need to put your plugin methods in setTimeout(). A great reminder to reread info about event loops! |
clearChoices still doesn't work.
|
Any advance in this issue for |
Nevermind, I just solved it:
|
I see that, there is one parameter which is accepted by the function |
Call the destroy() method first and then init() const example = new Choices(element); |
It's work for me. Thanks. |
I haven t found a way to do it programmatically...
Clear input clears the text but that’s it...
The text was updated successfully, but these errors were encountered: