I am able to dynamically create a lightning:radioGroup component, but when I add the 'onchange' property it fails to render. As soon as I remove that property it works again. I get the same error with 'onfocus', 'onblur'. These are all valid properties defined in the documentation for lightning:radioGroup.
I should note that I am able to successfully assign a function reference to the 'onclick' property of a lightning:buttonStateful in the same way.
The the error is "Action failed: c:radioButtonTest$controller$doInit [h.descriptor is undefined]".
I have seen this in two different orgs. Is this a bug?
Is there a workaround short of creating a listener for the radiobuttons? I need to create them dynamically because I need to assign a dynamic aura:id.
component:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
<aura:attribute name="radioGroupOptions" type="List" default="[{'label': 'Button One', 'value': 'one'},{'label': 'Button Two', 'value': 'two'}]"/>
<aura:attribute name="radioGroup" type="Aura.Component" />
<aura:attribute name="radioGroupValue" type="String" default="one"/>
<aura:attribute name="stateButton" type="Aura.Component" />
<aura:attribute name="buttonState" type="Boolean" default="false"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<div>{!v.radioGroup}</div>
<div>{!v.stateButton}</div>
</aura:component>
controller:
({
doInit : function(component, event, helper) {
$A.createComponent("lightning:radioGroup",
{
"aura:id": "findableAuraId",
"name": "radioGroup1",
"label": "Radio Group Test",
"type": "button",
"options": component.getReference("v.radioGroupOptions"),
"value": component.getReference("v.radioGroupValue"),
"onchange": component.getReference("c.onRadioGroupChange")
},
function(newRadioGroup, status, errorMessage){
if (status === "SUCCESS") {
component.set("v.radioGroup", newRadioGroup);
}
}
);
$A.createComponent("lightning:buttonStateful",
{
"aura:id": "findableAuraId",
"name": "button1",
"variant": "neutral",
"labelWhenOff": "Off",
"labelWhenOn": "On",
"labelWhenHover": "Change",
"title": "On-Off Button",
"state": component.getReference("v.buttonState"),
"onclick": component.getReference("c.onButtonChange")
},
function(newButton, status, errorMessage){
if (status === "SUCCESS") {
component.set("v.stateButton", newButton);
}
}
);
},
onRadioGroupChange : function(component, event, helper) {
console.log('changing...');
},
onButtonChange : function(component, event, helper) {
var buttonstate = component.get('v.buttonState');
component.set('v.buttonState', !buttonstate);
}
})