Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

chosen trigger error, if select is empty #738

Closed
rvinokurov opened this Issue Jul 25, 2012 · 2 comments

Comments

Projects
None yet
3 participants

I have dynamic select, and some times this select has no option. Error triggered on:

  Chosen.prototype.results_reset = function() {
            this.form_field.options[0].selected = true;
....
TypeError: this.form_field.options[0] is undefined
http://localhost/current/js/vendors/jquery/plugins/chosen.js
Line 697

Can you add a check on the length of an array of options?

Contributor

pfiller commented Apr 25, 2013

I'm not able to recreate this. Please provide a fiddle demonstrating the problem in action before re-opening.

@pfiller pfiller closed this Apr 25, 2013

Prepending an empty <option value="1"></option> tag in your select HTML, should work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment