Disabling an option after opening the dropdown

Disabling an option like this works if the dropdown has not yet been opened:

example1.find('option').eq(1).attr('disabled', 'disabled');

However it does not work if the dropdown has already been opened. If the dropdown has been opened, the only way I can disable the option is by replacing the option completely with a new identical option that has the disabled attribute set, like this:

var newOption = example1.find('option').eq(1).clone();
newOption.attr('disabled', 'disabled');

Here’s a fiddle showing 3 cases:

  1. opening the dropdown, changing the disabled attribute, re-opening (doesn’t work)
  2. opening the dropdown, replacing the disabled option, re-opening (works)
  3. changing the disabled attribute, opening (works)


It seems to me that #1 should work whether or not the dropdown has been previously opened. Is that correct?


Shoot, my fiddle used select2 4.0.2. It works with 4.0.12. Nevermind.