2

i have a problem to catch a fired event, everything is in place (i think) but the component that should catch the event simply does not, here is my code:

The function that fire the event ( ContractList):

updateTable: function(component, event, helper) {

    var cmpTarget = component.find('Confirmation');
    $A.util.removeClass(cmpTarget, 'slds-show');
    $A.util.addClass(cmpTarget, 'slds-hide');
    var ItemTobeUpdated = component.get("v.ItemToBeUpdated");
    var updateEvent = component.getEvent("UpdateTableItem");
    updateEvent.setParams({ "contract": ItemTobeUpdated });
    updateEvent.fire();

console.log('Event fired'); },

The component markup (ontractList):

    <aura:attribute name="contracts" type="Contract[]"/>
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="ItemToBeUpdated" type="Contract" />
    <aura:registerEvent name="UpdateTableItem" type="c:ContractItemUpdate"/>
    <aura:handler name="SendConfirmationBox" event="c:SendConfirmationBoxEvent"
   action="{!c.DispalyNotification}"/>

the component function that should catch the event (Contracts):

  handleUpdateContract: function(component, event, helper) {
        console.log('Je suis dans handleUpdateContract');
        var updatedContract = event.getParam("contract");
        console.log(updatedContract);
        helper.updateContract(component, updatedContract);
    }

the markup (Contracts)

    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="contracts" type="Contract[]"/>
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
   <aura:handler name="UpdateTableItem" event="c:ContractItemUpdate"
   action="{!c.handleUpdateContract}"/>
   <aura:registerEvent name="NotifierUtilisateurMessageEvent" type="c:NotifierUtilisateurMessage"/>

Just to be clear, the console.log('Event fired') is printed out when the event is fired, so the problem would be in the catcher component.

11
  • I don't see anything wrong with the code. Just a wild guess, Do you think is there any chance that event is fired before the receiving component is ready?
    – javanoob
    Jan 11, 2017 at 16:37
  • No, the receiving component get executed first when the page loaded, i do not think that this is the reason @javanoob. Unless there is something missing, i would go for a salesforce bug.
    – user28829
    Jan 11, 2017 at 16:44
  • We have similar code running on Spring 17, Winter 17 and it is working fine. I don't think Salesforce bug.
    – javanoob
    Jan 11, 2017 at 16:48
  • Are you trying this on Spring 17?
    – javanoob
    Jan 11, 2017 at 16:58
  • No i am on winter
    – user28829
    Jan 11, 2017 at 17:02

0

You must log in to answer this question.

Browse other questions tagged .