Skip to content
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

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

Closed
EmeraldWeb opened this issue Jun 14, 2019 · 6 comments · Fixed by #1166
Closed

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

EmeraldWeb opened this issue Jun 14, 2019 · 6 comments · Fixed by #1166

Comments

@EmeraldWeb
Copy link

EmeraldWeb commented Jun 14, 2019

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.

@EmeraldWeb EmeraldWeb changed the title Do not remove <option>'s inside the <select>. Do not remove <option>'s inside the <select>. Jun 14, 2019
@EmeraldWeb EmeraldWeb changed the title Do not remove <option>'s inside the <select>. Do not remove <option>'s inside the <select>. Jun 14, 2019
@jrockowitz
Copy link

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
Copy link

dexcell commented Oct 9, 2019

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
Copy link
Collaborator

Happy to review a PR that resolves this 👍

@dominik-tran
Copy link

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

@weha
Copy link

weha commented Jan 5, 2024

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

@Xon Xon linked a pull request Aug 6, 2024 that will close this issue
9 tasks
@Xon Xon removed the accepting PRs label Aug 22, 2024
@Xon
Copy link
Collaborator

Xon commented Aug 22, 2024

Implemented as part of v11.0.0

@Xon Xon closed this as completed Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants