option attribute disabled="disabled" #480

wants to merge 4 commits into


None yet

8 participants


Handle the disabled attribute of select options. Fixes #479


I would really like to see this behavior in select2.

Select2 member

The current version will break if Select2 is not attached to a <select> element.


@kevin-brown I'm not sure I understand, isn't Select2 always attached to a <select> and not to anything else?

Select2 member

Select2 can be attached to an <input type="hidden" /> for things like AJAX data and using a data array.

This implementation looks for result.element which is only present if it is attached to a <select> element.


Damn, this is a deal breaker for me at the moment and sadly I do not have time to fix it myself. Hope to see it fixed and merged soon. Thanks for the effort so far @loxK.

Select2 member

@ootoovak It will work fine if you only use Select2 attached to a <select> element. You just need to grab the code from this pull request. I'm pretty sure it is up to date with the current master.

If you attach it to an <input> tag... then you need to wait for the fix.


@kevin-brown cheers, I'll give it a go. I didn't look forward to rolling back to Chosen at this point in time.


Better do

disabled = result.element ? result.element[0].disabled : false;

to cover the case where it's not a <select>


By the transitive property, this would fix #157.

@ivaynberg ivaynberg closed this in 8e9a231 Jan 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment