0

I am on step 6 (Display Boat Details) of lightning component framework specialist superbadge, and created a boatselected event. I am firing the event from BoatTile component and receiving it in the onBoatSelected handler method of BoatDetails component.

When I checking the console output, I am not seeing the receiving log entry from "BoatDetailsController.js". Is there a way to check whether the application event is correctly fired from Tile component without the console.log

BoatTile.cmp

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

BoatTileController.js

var boatselected = component.get("v.boat");
var boatSelectedEvent = $A.get("e.c:BoatSelected");
boatSelectedEvent.setParams({ "boatselected" : boatselected });
console.log("Firing BoatSelected Event");
boatSelectedEvent.fire();

BoatDetails.cmp

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

BoatDetailsController.js

onBoatSelected : function(component, event, helper) {
        console.log("Receiving BoatSelected Event");
    }
  • Could you share the event code as well? Just want to check how you have defined it. Type should be application and there should be a param definition as well. – Ranga Jun 22 '18 at 23:41
  • RedDevil is correct, application events don't need name attribute. – madajee Jun 24 '18 at 13:29
3

You are firing an application event and the application event handlers should not have a name attribute below

<aura:handler event="c:BoatSelected" action="{!c.onBoatSelected}"/>

From documentation here

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

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.