I have a child component
<aura:component controller="campingController">
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:registerEvent name="add" type="c:enqueueEvent" />
<lightning:button label="test" onclick="{!c.doInit}"/>
</aura:component>
In its init I am firing a event
doInit : function(component, event, helper) {
var evt = component.getEvent('add');
evt.setParams({
actionobject:''
});
evt.fire();
}
Its parent component is handling this event
<aura:component >
<aura:handler name="add" event="c:enqueueEvent"
action="{!c.addInQueue}" includeFacets="true"/>
<c:child/>
</aura:component>
I am not able to handle event in parent that was fired by child on init.
I know that might be due to reason that Child is initialised first then parent is initialised.
I have gone through Communication between parent and child Lightning components during initialization and Lightning component event not fired or handled but firing application event on init of parent is not a workable solution for me.
do we any other workaround?