I have a component which consists of another child component which is added dynamically:
<aura:component>
<ltng:require styles="/resource/SLDS0122/assets/styles/salesforce-lightning-design-system-ltng.css" />
<aura:attribute name="attachments" type="Aura.Component[]" description="Array of Components for adding attachement components"/>
<aura:handler name="removeAttachment" event="c:removeAttachment" action="{!c.removeAttachment}"/>
<div class="slds-attachments">
<!--File attachment components are added here -->
{!v.attachments}
</div>
</aura:component>
And child component which has a registered event as follows:childComponent
<aura:component>
<!-- Handler -->
<aura:Handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:registerEvent name="removeAttachment" type="c:removeAttachment"/>
<button class="slds-button slds-button--icon-bare" onclick="{!c.fireRemoveAttachmentEvt}"/>
</aura:component>
Controller:
{
fireRemoveAttachmentEvt : function(cmp,evt,hlpr){
console.log("Inside fireRemoveAttachmentEvt");
var removeAttachEvt = cmp.getEvent("removeAttachment");
console.log(removeAttachEvt.getName());
removeAttachEvt.fire();
},
}
Now i am able to handle the event if put a handler in the same component, but if i try to handle the event in an another component, the method referenced in the action attribute of handler is not executed.
Any help on this greatly appreciated. Thank you.