I have this lightning:select component:

<lightning:select name="theme" aura:id="theme" label="Theme:" onchange="{! c.changeTheme }">
            <option value="StandardSalesforce">Standard Salesforce</option>
            <option value="Halloween">Halloween</option>
            <option value="Bloodthirsty">Bloodthirsty</option>
            <option value="Midnight">Midnight</option>

How can I disable one of the options in the onchange controller method ?



You can dynamically reset the values of the lightning:select by giving new set of values in the controller.

You can get more details from this. lightning:select.


I did a kind-of hacky thing

<option disabled="{! v.defaultDisabled }" ... />

then in the controller

component.set("v.defaultDisabled", true);

but maybe there is a different way....

  • 1
    I am sure if that will not work in modern browsers because the presence of word disabled will disable the option regardless the value (true or false). – manjit5190 Feb 21 '18 at 13:31
  • It works on my machine – SallyRothroat Feb 21 '18 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.