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

If select container is not visible when initializing chosen() width is set to zero #1267

Closed
jonhenning opened this issue Jun 7, 2013 · 2 comments

Comments

@jonhenning
Copy link

Here is a sample fiddle (http://jsfiddle.net/uQ685/).

Changing the code to use jQuery to grab container width is one way to resolve the problem.

AbstractChosen.prototype.container_width = function() {
  if (this.options.width != null) {
    return this.options.width;
  } else {
      //return "" + this.form_field.offsetWidth + "px";
      return $(this.form_field).width() + "px";    // use jquery to calculate, as we don't want 0
  }
};
@pfiller
Copy link
Contributor

pfiller commented Jun 7, 2013

You can initialize Chosen using a width to get around this:

$("select").chosen({ width: '350px' });

Duplicate of #92

@pfiller pfiller closed this as completed Jun 7, 2013
@justabuzz
Copy link

It's closed, but I downloaded 1.0 and it's still happening. I tweaked the JS file according to the OP's suggestion and problem fixed.

FYI.

Thanks for a great library! :)

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