0

Is it possible to disable a toogle if is checked ?

<lightning:input type="toggle"  name="togglevalue" checked="false" messageToggleActive="ok" messageToggleInactive="not ok"  disabled="{!if checked}" />
3

Answer is yes. You can do it. Firstly you need to declare one variable in component and need to assign in lightning input value and same can be used into disable attribute.

<aura:attribute name="toggleFieldValue" type="boolean" default="false" />

<lightning:input type="toggle"  name="togglevalue" checked="{!v.toggleFieldValue}" messageToggleActive="ok" messageToggleInactive="not ok"  disabled="{!v.toggleFieldValue}" />
|improve this answer|||||
1

Yes its possible, you just have to use your boolean field on the object.

<lightning:input type="toggle"  name="togglevalue" checked="false" messageToggleActive="ok" messageToggleInactive="not ok"  disabled="{!v.yourObject.yourObjBoolean}" />

Or the boolean attribute value populated.

<aura:attribute name="yourBoolean" type="boolean" default="false" />
<lightning:input type="toggle"  name="togglevalue" checked="false" messageToggleActive="ok" messageToggleInactive="not ok"  disabled="{!v.yourBoolean}" />

Providing a little more code might help us help you more. More context helps get better answers! :)

|improve this answer|||||
1
<aura:attribute name="togglecheck" type="Boolean"/>    
<lightning:input type="toggle"  name="togglevalue" checked="{!v.togglecheck}" messageToggleActive="ok" messageToggleInactive="not ok"  disabled="{!v.togglecheck}" />
|improve this answer|||||

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.