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

Select in a div that's hidden on page load #2309

Closed
MK-Chris opened this issue Apr 9, 2015 · 5 comments · May be fixed by #2495
Closed

Select in a div that's hidden on page load #2309

MK-Chris opened this issue Apr 9, 2015 · 5 comments · May be fixed by #2495

Comments

@MK-Chris
Copy link

MK-Chris commented Apr 9, 2015

Hi

I seem to have hit an issue using Chosen to generate a select list in a div element that's hidden on page load. If the div is then shown, the select list has no width and you can't see any item text. You should be able to see what I mean with the below JSFiddle:

http://jsfiddle.net/mamwuen5/

2015-04-09_14-57-14

If the div is not hidden on page load, you can hide and show it to your heart's content, as in the below JSFiddle:

http://jsfiddle.net/mamwuen5/2/

Am I doing something wrong, or is this a bug?

Thanks

Chris

@briannesbitt
Copy link

For what its worth I just came across this having a chosen select in a bootstrap modal.

Fixed it by using $("select").chosen({width: "100%"}); option.

@MK-Chris
Copy link
Author

Thank you - I was hoping to have it use the width specified in the CSS, which is why it wasn't specified (as I have selects of differing sizes sometimes), but I can try and work around that.

@Salik-Rafiq
Copy link

This is probably the most annoying "feature" of this control. I tried Select2 and it doesn't have this limitation.

What I did was something akin to
$('.droplist').each(function(){
var css_width = $(this).css("width");
$(this).chosen({width: css_width});
}

which works okay for me.

@alar1
Copy link

alar1 commented Jan 18, 2016

this whorks for me:
$(".chosen-select").chosen('destroy');
$(".chosen-select").chosen({width: "100%"});

@pfiller
Copy link
Contributor

pfiller commented Jun 2, 2016

Duplicate of #92

@pfiller pfiller closed this as completed Jun 2, 2016
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.

5 participants