1

I am not able to get the reference to an application level Lightning Event inside an Lightning component.

I have defined an application level event named 'MemberEvent' and I have registered it in component UI like this,

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

Now inside an action of js controller, I am trying to call this event like,

var mEvent = $A.get("e.c:MemberEvent");

But in mEvent is undefined and I am not able to set the parameter. This is a general format to get an event but I am not able to understand why I am not getting this reference. Please help me here if I am missing any of the steps or check to invoke an event.

Thanks

  • Have you given name in handler for the application event?. It wont work if you have given name when declaring handler for application events? – RedDevil Nov 20 '17 at 6:39
  • 1
    Thanks @RedDevil, Yes I am giving the name in handler as well like this <aura:handler event="c:MemberEvent" action="{!c.eventHandler}"/> The problem is that I am not even able to setParams for the event. The error is like Cannot read property 'setParams' of undefined – Om Ksolves Nov 20 '17 at 7:35
  • Welcome to SFSC, Please read How to Ask and add your complete component code – Himanshu Nov 20 '17 at 8:49
2

Never mind, I have fixed my problem. I was not getting the reference because The event was application and its access was Global but the components were not and The code was from an unmanaged package.

So my observations are that the application level event should be global and all the implementing component should also be global if you want to access it from a package.

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.