0

I don't know what wrong happens is with my Application. Wherever I have written the javascript code to get Application event, it always returns undefined. And my code is just simple as written below.

var appEvent = $A.get('e.c:EventName');
appEvent.fire(); // Here I got appEvent undefined

1
  • Will you please share more info? Perhaps the event that you created, the registerEvent snippet etc. Commented Nov 16, 2017 at 10:22

1 Answer 1

1

Did you register your event in your component?

<aura:registerEvent name="unused" type="c:EventName"/>

As documented here.

It also states:

Use $A.get("e.myNamespace:myAppEvent") in JavaScript to get an instance of the myAppEvent event in the myNamespace namespace.

so you need to replace c with your namespace.

4
  • 1
    Perhaps you want to add a link to the documentation: developer.salesforce.com/docs/atlas.en-us.lightning.meta/…
    – Folkert
    Commented Nov 16, 2017 at 9:52
  • @Basti, I already did it. Commented Nov 16, 2017 at 9:54
  • @KapilKaushik I edited it, after he reminded me :)
    – itsmebasti
    Commented Nov 16, 2017 at 9:56
  • @Basti - I already tried this also. Well if we are putting the 'c' instead of namespace then Salesforce replace it with namespace itself. Commented Nov 16, 2017 at 10:02

You must log in to answer this question.

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