1

I'd like to disable a Lightning button under certain conditions.

<aura:attribute name="showSecurityComponent" type="Boolean" />
<aura:attribute name="checkCaptcha" type="Boolean" default="true"/>
<aura:attribute name="removeUserDisableButtons" type="Boolean" />

The intent is to disable the button if 1) both showSecurityComponent and checkCaptcha are true, 2) or if removeUserDisableButtons is true.

I'm passing all three value params inside the disabled property of the button:

<lightning:button aura:id="saveButtonEdit"
                  variant="brand"
                  label="Save and continue"
                  onclick="{! c.saveEditClick}"
                  disabled="{!and(v.checkCaptcha,v.showSecurityComponent,v.removeUserDisableButtons)}" />

But this isn't disabling the buttons. I'm not sure what's wrong with the syntax.

1 Answer 1

2

did you try this?

<lightning:button aura:id="saveButtonEdit"
                  variant="brand"
                  label="Save and continue"
                  onclick="{! c.saveEditClick}"
                  disabled="{!or(and(v.checkCaptcha,v.showSecurityComponent),v.removeUserDisableButtons))}
1
  • Thanks, {!or(and(v.checkCaptcha,v.showSecurityComponent),v.removeUserDisableButtons)} works exactly how I hoped. Need to read up on the and / or syntax.
    – Matt Smith
    Commented Feb 13, 2020 at 1:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .