1

I have the following code in my lightning component

 <lightning:input type="checkbox" label="Life" aura:id="checkboxField"
                             value="{!v.isLifeChecked}" 
                             onchange="{!c.handleLifeCheckboxCheck}"/> 

 <lightning:button label="Clear"
                                  class="slds-button slds-m-right_x-small"
                                  onclick="{!c.onClear}" iconPosition="right"/>

and the following code in the helper

onClear : function(component, event, helper) {
    component.find("checkboxField").set("v.value", false);
},

My isssue here is that, on click of the clear button, the checkbox does not get deselected.

I also tried setting

isLifeChecked as false in jscontroller, but that does not work either

2

the attribute for that in lightning:input is checked (not value) for checkbox type

<lightning:input type="checkbox" label="Life" aura:id="checkboxField"
                         checked="{!v.isLifeChecked}" 
                         onchange="{!c.handleLifeCheckboxCheck}"/>

Also in javascript you have to set checked only

component.find("checkboxField").set("v.checked", false);
| improve this answer | |
  • i did not not change the value attribute, but without the value attribute I will not be able to perform some functionalities. The v.checked wroks perfectly. – user55791 Aug 8 '19 at 8:09

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.