0

I am having trouble doing a basic task of setting a component attribute in my controller. I define the attribute in the component, get the value of the radio button option selected & want to set the value of the attribute. I am not able to set the attribute.

Main component

            <lightning:radioGroup aura:id="amountDueRadioButton" 
                          label="Select a registration Option"
                          name="registrationOption"
                          checked="{!v.amountDue}" 
                          onchange="{!c.calculateAmountDue}"                       
                          type="radio"
                          options="{! v.registrationOptions }"
                              required="true"/>

Controller

        calculateAmountDue: function(component, event, helper) {
             var registrationOption = event.getSource().get("v.value");
             if (registrationOption=="Open Day ONLY") {
             alert("before component set");  ** this works **
             component.set("v.amountDue", 10);
             alert("after component set"); *never get to this **
1

Actually, there is no checked attribute for lightning:radioGroup. So that might be causing the error and you need to remove it.

checked="{!v.amountDue}

If you want to set a value, you can use value="{!v.amountDue}". Make sure the value you are setting is available in the list of options you are providing.

1

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.