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

chosen-container getting width: 0px #1548

Closed
gandarez opened this issue Sep 12, 2013 · 5 comments
Closed

chosen-container getting width: 0px #1548

gandarez opened this issue Sep 12, 2013 · 5 comments

Comments

@gandarez
Copy link

I've the latest version of chose (1.0.0) and I'm getting width: 0px within chosen-container. I have no idea why the function this.container_width() has been returning "0px". Someone could help me?

note: I'm using inside a bootstrap modal which shows on the fly
note2: I must call modal() and then call chosen() to not get fail

@paranoidd
Copy link

I encountered exactly the same issue, and what solved this me was adding a
min-width: 220px !important;
to the .chosen-container CSS class :)

@koenpunt
Copy link
Collaborator

Duplicate of #1272 and #1532, possible solution in #1439

@ChuckNorrison
Copy link

I searched for this issue about 1 hour. I wasnt sure if it come since the latest update to 3.2... i fixed it with chosen.css and width: 220px !important

Its not a good solution, it should be fixed with next joomla update... this issue is nearly 1 year old.

tdesvenain added a commit to tdesvenain/collective.z3cform.chosen that referenced this issue Sep 1, 2014
@zalza13
Copy link

zalza13 commented Mar 18, 2016

In the code of "chosen.jquery.js" look:

container_props = {
'class': container_classes.join(' '),
'style': "width: " + (this.container_width()) + ";",
'title': this.form_field.title
};

Then simply do:

$("#idControl").chosen({
width: "250px"
});

@chrisjefferies
Copy link

I realize this is a bit old, but I've come up with a marginally better solution (for 1.7.0) by adding the following function:

function defModalWidth(obj) {
  if (obj.container_width() == '0px') {
    return '600px';    
  } else {
    return obj.container_width();
  }
}

and replacing this.container_width() in set_up_html by calling it thusly:

this.container.width(defModalWidth(this));

Anything that chosen thinks should be zero because the modal it's in is hidden will get 600 instead.

Seems to work.

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

6 participants