function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jiri UlipJiri Ulip 

Lightning Components - basic design challenge

Hello,

I'm working on getting the action handling challenge (https://developer.salesforce.com/trailhead/lex_dev_lc_basics/lex_dev_lc_basics_controllers) and although I believe my code is correct and does what it's expected to do (see below), I'm getting "Challenge Not yet complete... here's what's wrong: The campingListItem JavaScript controller isn't setting the 'item' attribute correctly." Could I get a hint on what's going on?

Cheers,

Jiri
({
    packItem : function(component, event, helper) {
   
       component.set("v.item.Packed__c", true);     
       event.getSource().set ("v.disabled", true);
        
    }
})

 
Best Answer chosen by Jiri Ulip
Jeff DouglasJeff Douglas
Try adding the following line of code to trigger the update value provider:
 
component.set("v.item",item);

Jeff Douglas
Trailhead Developer Advocate

All Answers

Jeff DouglasJeff Douglas
Try adding the following line of code to trigger the update value provider:
 
component.set("v.item",item);

Jeff Douglas
Trailhead Developer Advocate
This was selected as the best answer
Jiri UlipJiri Ulip
Thanks for the quick fix! It throws an error in my preview app, but it allowed me to pass the challenge :). The point is that I got the point that I need to set the whole thing after I modified its part :). Hopefully I'll get up to speed eventually.
Nicolas CumulusNicolas Cumulus
Jeff, I was stuck in the same spot and your fix worked. Unfortunately, I wrote exactly the same code as Jiri, and I don't understand the contents of your fix. Where does the item var come from? Why isn't just setting v.item.Packed__c good enough?
Nicolas CumulusNicolas Cumulus
The next module does a good job of explaining why component.set("v.item", something); is necessary; I guess the item variable must be inherited from the component's aura:attribute, although it's unclear to the user at that point in the trail.