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

Instantiating chosen on a hidden select field #2883

Closed
TetHat opened this issue Sep 6, 2017 · 1 comment
Closed

Instantiating chosen on a hidden select field #2883

TetHat opened this issue Sep 6, 2017 · 1 comment

Comments

@TetHat
Copy link

TetHat commented Sep 6, 2017

As mentioned in the options of chosen, when you instantiate chosen on a hidden select field, the chosen select box width is 0 unless you define a width in the JS call.

This can be fixed by changing line 559 in chosen.jquery.js from return this.form_field.offsetWidth to window.getComputedStyle(this.form_field, null).width. This will return the value 150px when width: 150px is set on the original select field in CSS.

This is a much more robust solution that allows for easier customization of widths through CSS rather than needing multiple JS calls for each hidden select field that has a different width.

@tjschuck
Copy link
Member

Pretty sure this is a duplicate of the long-standing #92. Please feel free to leave any additional feedback you have there. There's also a number of workarounds offered up on that issue.

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

2 participants