0

Lightning Event:

tripEventer, attribute - trip, Trip__c

Component Item:

<aura:registerEvent name="openTripEvent" type="c:tripEventer"/>
<lightning:button class="slds-align_absolute-center" onclick="{!c.openTripAction}" label="Open Form"/><br/>

Component Item Controller:

openTripAction: function (component, event, helper) {
var action = component.getEvent('openTripEvent');
action.setParam('trip', component.get("v.trip"));
action.fire();
alert('gree from item button');
}

Component Form:

<aura:attribute type="String" name="test" default="nothing"/>
<aura:handler name="openTripEvent" action="{!c.handleOpenForm}" event="c:tripEventer"/>

Component Form Controller:

handleOpenForm: function (component, event, helper) {
component.set("v.test", "something");
alert('im here');
}

and I don't see alert 'i'm here, handleOpenForm js-action isn't fired

1

Do not specify the name attribute on an aura:handler for application events. This is specifically stated in the documentation:

The handler for an application event won’t work if you set the name attribute in <aura:handler>. Use the name attribute only when you’re handling component events.

Removing the name attribute should resolve the problem.

  • but it's component event.i thought about it. so you think that [item component] inside of [list component] can't catch [form component]? just change to application event? – Ivan S. Jun 6 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.