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
Susan ThomlinsonSusan Thomlinson 

Trouble resolving error on Handle Actions with Controller Challenge

I am getting the following error when trying to pass this challenge:

Challenge Not yet complete... here's what's wrong:
The campingListItem JavaScript controller isn't setting the 'Packed' value correctly.

Here is is code for component:
<aura:component >
    <aura:attribute name="item" type="Camping_Item__c" required="true"></aura:attribute>
    <p>Name: <ui:outputText aura:id="outText" value="{!v.item.Name}"></ui:outputText></p>
    <p>Packed?: <ui:outputCheckbox aura:id="chkPacked" value="{!v.item.Packed__c}"></ui:outputCheckbox></p>
    <p>Price: <ui:outputCurrency value="{!v.item.Price__c}"></ui:outputCurrency></p>
    <p>Quantity: <ui:outputNumber value="{!v.item.Quantity__c}"></ui:outputNumber></p>
    <p><ui:button aura:id="outButton" label="Packed!" press="{!c.packItem}" /></p>

Here is the controller:
    packItem : function(component, event) {
     var chkPacked = component.find("chkPacked");
     var btnClick = event.getSource().find("outButton");
     btnClick.set(chkPacked, true);
     btnClick.disabled = true;
Please help me to resolve this error;

Jeff DouglasJeff Douglas

Try doing the following in your controller. First get the item from the form.
var item = component.get("v.item");

Then set the item's Packed__c field equal to true. Then use compent.set to set the item back to the v.item provider.

Then since the button is the event that triggered the process, you can do event.getSource() and then do .set and set the v.disabled to true.


Jeff Douglas
Trailhead Developer Advocate