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");
    }
2
  • 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
    Commented Jun 22, 2018 at 23:41
  • RedDevil is correct, application events don't need name attribute.
    – madajee
    Commented Jun 24, 2018 at 13:29

1 Answer 1

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.

0

You must log in to answer this question.

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