0

The event is not listened when I switch the option from a radiobutton group. "here AE" is never shown on console

Event

<aura:event type="COMPONENT" description="Event to chage the format of fields when radio button changes" >
    <aura:attribute name="format" type="String" description="Format name" />
</aura:event>

Mother Component

<aura:registerEvent name="PercentDolarFormatChangeEvent" type="c:PercentDolarFormatChangeEvent"/>

<aura:attribute name="radioButtonOptions" type="List" default="[
                                                        {'label': 'Amount $', 'value': 'Currency'},
                                                        {'label': 'Percent %', 'value': 'Percent-Fixed'}
                                                        ]"/>
    <aura:attribute name="radioButtonChosenOption" type="String" default="Currency"/>

<lightning:radioGroup name="radioGroup"                          
                              options="{! v.radioButtonOptions }"
                              value="{! v.radioButtonChosenOption }"
                              onchange="{! c.radioButtonOptionChange }"
                              type="radio"/>

Mother component controller:

radioButtonOptionChange: function(component, event, helper) {
        
        if(component.get("v.radioButtonChosenOption") === 'Currency'){
            component.set("v.PercentAmoutTitle", "Amount $");
        }else{
            component.set("v.PercentAmoutTitle", "Percent %");            
        }            
        component.getEvent("PercentDolarFormatChangeEvent").setParams({"format" : component.get("v.radioButtonChosenOption")}).fire();  
        
    },

Child component:

<aura:handler name="PercentDolarFormatChangeEvent" event="c:PercentDolarFormatChangeEvent" action="{!c.HandleFormatChangesEvt}"/>

Child component controller:

HandleFormatChangesEvt : function(component, event, helper){
        console.log("here AE");
        console.log(event.getParam("format"));
        //component.set("v.amountOrPercent", event.getParam("format"));
    }
2

1 Answer 1

0

As @Pavlo answered it worked after switching everything from a Component to an Application event (where everybody listens)

You must log in to answer this question.

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