2

It looks like the event is firing but the handler is not catching it. How do I go about getting this component event to be handled?

EVENT:

<aura:event type="COMPONENT" ></aura:event>

Registered event:

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

Event Fire:

    updateTimes : function(component, event, helper) {
    var updatetimes = component.getEvent("EnterTimeSheet");
    console.log('update fired')
    updatetimes.fire();
}

Handler:

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

Handler JS:

updateSheet : function(component, event) {
    console.log('LETS UPDATE');
}
3

1 Answer 1

0

A component event will not be caught by child components and while an application event will be caught, it's very expensive and inefficient - it really should be only used when absolutely necessary - ie communication between unconnected sibling components for example.

To communicate with a child, you can use an attribute (with or without a change handler) and for anything a bit more complex, you should use an aura:method.

Child component (c:child):

<aura:component>
  <aura:method name="updateSheet" action="{!c.updateSheet}" />
  <!--this can call the same updatesheet method you call in your question -->

Parent component:

<aura:component>
  <child aura:id="childCmp" />

Parent code (controller or helper):

component.find("childCmp").updateSheet()
//you can also call with parameters - look up dev guide for example

You must log in to answer this question.

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