Going the the lightning trailhead I'm at the challenge for camping list events. Everything is done in the CampingForm and all seems to work

In the form component

<aura:registerEvent name="addItem" type="c:addItemEvent"/>

the form controller validates and all works and calls this helper

createItem : function(component, citem) {
    var createEvent = component.getEvent("addItem");

All seems to work fine Now in the campinglist component I need to handle that event When I add this and try to save it

<aura:handler name="addItem" type="c:addItemEvent" action="{!c.handleAddItem}" />

I get this error

'Failed to save undefined: aura:handler has invalid name attribute value: addItem'

Any ideas why it doesn't like this. I'm doing pretty much the exact same thing that works in the expense app so I am at a loss as to why I cannot save this.

  • There is a problem with the <aura:handler/> syntax, before that can you confirm whether c:addItemEvent is an Application or Component event?
    – Praveen
    Aug 10, 2016 at 17:41
  • this is the definition of the addItemEvent <aura:event type="COMPONENT" > <aura:attribute name="item" type="Camping_Item__c" /> </aura:event> what is the problem with the <aura:handler syntax that you see?
    – Ohmicron
    Aug 10, 2016 at 17:50
  • Can you change type to event: <aura:handler name="addItem" event="c:addItemEvent" action="{!c.handleAddItem}" /> Does that work?
    – Praveen
    Aug 10, 2016 at 17:52
  • Try changing type="c:addItemEvent" to event="c:addItemEvent" - and remove the invalid 'name' attribute. Aug 10, 2016 at 17:52
  • Thanks Caspar. I think that was it. Now I'm getting one of those totally generic errors. Error during init [TypeError: Cannot read property 'apply' of undefined] usually caused by a stupid typing syntax error but at least it is now letting me save the code with the handler tag.
    – Ohmicron
    Aug 10, 2016 at 17:56

1 Answer 1


Since the addItemEvent is an COMPONENT event. You need to give the name,event and it action attribute.

Looking at your code, changing the type to event would solve the issue.

<aura:handler name="addItem" event="c:addItemEvent" action="{!c.handleAddItem}" />

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.