option attribute disabled="disabled" #480

Closed
wants to merge 4 commits into
from

Projects

None yet

8 participants

@loxK

Handle the disabled attribute of select options. Fixes #479

@keleshev

I would really like to see this behavior in select2.

@kevin-brown
Select2 member

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

@keleshev

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

@kevin-brown
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.

@ootoovak

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.

@kevin-brown
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.

@ootoovak

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

@MikeBagos

Better do

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

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

@cvrebert

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