Choices-js / Choices

A vanilla JS customisable select box/text input plugin ⚡️
https://choices-js.github.io/Choices/
MIT License
6.25k stars 616 forks source link

Do not remove <option>'s inside the <select>. #601

Closed EmeraldWeb closed 3 months ago

EmeraldWeb commented 5 years ago

I really like this library, but there is one unpleasant thing for me - clearing the <option> as a result of the library. What prevents future improvements and maintenance through cross-functional scripts. I don’t know why you don’t save the original tag tree inside <select>, if this is necessary, then please add a parameter to preserve the original data structure.

jrockowitz commented 5 years ago

I just ran into a bug in the Webform module for Drupal related to <option> tags being removed and re-added.

The bug was related to trying to cache an option element via jQuery (see below) and then having this option element being removed by ChoicesJS.

var $otherOption = $element.find('option[value="_other_"]');

This is not a major issue and easy to work-around but I felt it was worth noting here.

dexcell commented 5 years ago

I also likes the lib, but turns out i can't use this plugin because the choices.js doesn't preserve the select options , so i can't attach html5 data to the option and use it for another js function. sadly i have to go back to select2 since it does preserve the options.

I hope this will implemented in next version. Ideally choices.js is the interface to a hidden select, but it does not modify the original select tag just like select2.

jshjohnson commented 5 years ago

Happy to review a PR that resolves this 👍

dominik-tran commented 3 years ago

Is there some update? I'm using version 9.0.1 and the issue still remains.

weha commented 10 months ago

Still in 10.2 :( I don't understand why something like this was a feature in the first place?

Xon commented 3 months ago

Implemented as part of v11.0.0