option attribute disabled="disabled" #479

Closed
loxK opened this Issue Oct 9, 2012 · 3 comments

Comments

Projects
None yet
5 participants

loxK commented Oct 9, 2012

The "disabled" parameter of the "option" tag is referenced (http://www.w3schools.com/tags/att_option_disabled.asp)

By default Select2 should handle disabled options like a regular select box does: grayed out and unselectable. Up to anyone to hack it using a custom formatter if it wants a non standard behavior.

Until this is fixed, I am trying to hack that standard behavior myself. I managed to add a "disabled" class using the formatResult callback, but I can't remove the 'select2-result-selectable' class of the parent li element, which would be enough to prevent the option from being selected by a user:

function formatt (state, container) {
    if( !state.element[0].disabled ) return state.text;
    $(container).addClass('disabled');
    $(container).parent('li').removeClass('select2-result-selectable');
    return state.text;
}

How did you make it work without #480? What is in your disabled class?

+1. This not being handled is actually a big issue for my app.

Contributor

cvrebert commented Jan 4, 2013

This seems to be a dupe of #157.

ivaynberg closed this Jan 4, 2013

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