I spent the whole day trying to figure out why this event is not getting fired, i tried both component and application events but noting worked although the code is pretty simple.
here is my code :
Event: EVT01_deleteItems
<aura:event type="COMPONENT" >
<aura:attribute name="item" type="To_do_Items__c"/>
</aura:event>
Child component: CMP03_Item
<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="TestContactLevels">
<aura:attribute name="Item" type="To_do_Items__c" />
<aura:registerEvent name="deleteItem" type="c:EVT01_deleteItems" />
<article class="slds-card">
<lightning:icon title="Supprimer la tache" iconName="utility:delete" size="xx-small" class="icon"
onclick="{!c.deleteItem}" />
</article>
Child component controller :
deleteItem : function(cmp, event, helper) {
var itemToBeDeleted = cmp.get("v.Item");
var deleteEvent = cmp.getEvent("deleteItem");
deleteEvent.setParams({"item": itemToBeDeleted });
deleteEvent.fire();
}
Parent component: CMP02_toDoListItems
<aura:component implements="flexipage:availableForAllPageTypes" access="global">
<aura:attribute name="itemsToDisplay" type="To_do_Items__c[]" />
<aura:handler name="deleteItem" type="c:EVT01_deleteItems" action="{!c.mDeleteItem}" />
<aura:iteration items="{!v.itemsToDisplay}" var="item">
<c:CMP03_Item Item="{!item}"/>
</aura:iteration>
Parent component controller:
mDeleteItem: function(cmp,event,helper){
// nothing here, just a console log
console.log("does it work ? ");
}
am i missing something here ?