Scenario I have a normal select box with class 'searchable' and normal html options (no ajax).
a choices instance is created:
choices = new Choices('select.searchable')
I destroy the choices instance
choices.destroy()
NOW, the Docs say that my select tag should be back to its original state.
HOWEVER instead, the select box is left blank (i.e no options in list)
Hey are you able to send me a JSFiddle or a Codepen highlighting the problem please?
I will when I get some free time. Currently I'm just storing the options for every select before it's instantiated, then putting the original back from my own variables
I can easily reproduce this as well. It's very inconvenient! Here ya go:
@DonGissel yep that is exactly the issue. Nice and concise fiddle
Thanks for the jsfiddle. This isn't so much a bug as it is a missing piece of functionality!
Out of interest, would you expect destroy() to restore select options as they were before Choices was initiated? Or would you expect it to create options based on the state of Choices - including which options have been selected etc?
Well, it emptying the original <select> I would very much classify as a bug. ;-)
That being said, I can see valid points for both restoring original state and persisting the new state. Perhaps a boolean option could be passed to destroy() to determine whether or not to update the original element, with the default being not to (false)?
I would say this is definitely classified as a bug, since the Docs say that on destroy, the element is put back to its original state
as for whether is should revert back to original, or new persisted state, the default in my opinion for a destroy function should be the original state
A flag to persist the current state would be helpful however
@jshjohnson What is the progress on this?
This has been fixed on the develop branch and will go out in the next release 馃憤
When that release is planned to happen... quite keen to get that functionality working, otherwise I'll have to fork it and do it myself
I also need this functionality to be released. Would be nice to have some kind of timeline.
This seems to be an issue in 6.0.3, see updated example: https://jsfiddle.net/pco03evt/
Should this be re-opened?
This is still a glitch in 8.0.0...
This is still a glitch in 8.0.0...
Most helpful comment
This has been fixed on the
developbranch and will go out in the next release 馃憤