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

Feature request - copy data-attr's and/or classes from original select #6254

Open
MakerTim opened this issue May 19, 2023 · 4 comments
Open

Comments

@MakerTim
Copy link

Context

You can hide options via CSS, display: none.
But when using select2 it has no effect.
My request is to add the data-attr's so

Preview

image
image

Codebin

https://jsbin.com/sicexew/edit?html,css,js,output

@AzzaAzza69
Copy link

In fact, I would suggest two select2 configuration options (defaulted to false if select2 dev wanted backward compatibility) of "copyOptionClasses": true|false and "copyOptionAttributes": true|false which would do exactly that!

@Shnoulle
Copy link
Contributor

More copy data attribute from options, but can be interesting.

Have a way to copy class too (by option)

@MakerTim MakerTim changed the title Feature request - keep data-attr's from original select Feature request - copy data-attr's and/or classes from original select Sep 20, 2023
@AzzaAzza69
Copy link

RE: Can I get a little bit more context on this feature request?

So if an option was defined as such (square instead of angle):
[option class="class" data-something="yes"]
then the corresponding would look like this:
[li class="select2-results__option class" data-something="yes"]

@MakerTim
Copy link
Author

Yes, something like that!

Something that you can share the CSS and display: none them both at the same time.
If you prefix the class, or data-items, that's fine as well

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

No branches or pull requests

3 participants