You need to sign in to do that
Don't have an account?
JeffreyStevens
Trailhead Challenge Lightning Components Basics, Connect Components with Event
I've read through several posts on the Connect Components with Events challenge, and I'm still not seeing what's wrong with my campingListController. I'm getting the Challenge Not yet complete message. "The campingList JavaScript controller isn't setting the 'item' as a parameter or saving the record correctly"
Can anybody tell me where I'm wrong?
campingList - component
campingList - Controller
Nothing in the helper.
Thanks!
Can anybody tell me where I'm wrong?
campingList - component
<aura:component controller="CampingListController"> <aura:handler name="init" action="{!c.doInit}" value="{!this}"/> <aura:handler name="addItem" event="c:addItemEvent" action="{!c.handleAddItem}"/> <div class="slds-page-header" role="banner"> <div class="slds-grid"> <div class="slds-col"> <p class="slds-text-heading--label">Camping Items</p> <h1 class="slds-text-heading--medium">My Camping Items</h1> </div> </div> </div> <div aria-labelledby="newitemform"> <fieldset class="slds-box slds-theme--default slds-container--small"> <c:campingListForm /> </fieldset> </div> <aura:attribute name="items" type="Camping_Item__c[]"/> <div class="slds-card slds-p-top--medium"> <header class="slds-card__header"> <h3 class="slds-text-heading--small">Camping List Items</h3> </header> <section class="slds-card__body"> <div id="list" class="row"> <aura:iteration items="{!v.items}" var="campItem"> <c:campingListItem item="{!campItem}"/> </aura:iteration> </div> </section> </div> </aura:component>
campingList - Controller
({ // // Load Camping Items at startup // doInit: function(component, event, helper) { // Create the action var action = component.get("c.getItems"); // Add callback behavior for when response is received action.setCallback(this, function(response) { var state = response.getState(); if(component.isValid() && state === "SUCCESS") { component.set("v.items", response.getReturnValue()); } else { console.log("Failed with state: " + state); } }); // Send action to be executed $A.enqueueAction(action); }, handleAddItem: function(component, event, helper) { var item = event.getParam("item"); var action = component.get("c.saveItem"); action.setParms({"item" : item}); action.setCallback(this,function(response){ var state = response.getState(); if (component.isValid() && state === "SUCCESS") { var items = component.get("v.items"); items.push(response.getReturnValue()); component.set("v.items", items); } }); $A.enqueueAction(action); }, })
Nothing in the helper.
Thanks!
I have posted the working solution in the below discussion please try and get it done.
https://developer.salesforce.com/forums/?id=9060G000000XhdHQAS
Thanks !
Happy to help you !!
All Answers
May I suggest you please check with below link from the forums community with similar issue and suggested workaround.
- https://developer.salesforce.com/forums/?id=906F0000000kDPpIAM
Hope this helps.Mark it as solved if it's resolved.
Regards,
Nagendra.
I have posted the working solution in the below discussion please try and get it done.
https://developer.salesforce.com/forums/?id=9060G000000XhdHQAS
Thanks !
Happy to help you !!
As "newItem" is already been declared in list controller Don't worry about this line it's working for me and I passed the challenge.
Did you tried it !
Thanks !1
And campingListController...