• Hasmukh Jain 2
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi All,

I am not able to complete the challenge "Mark Item as Packed" getting error message  The campingListItem JavaScript controller isn't setting the 'Packed' value correctly.

Below is the code, please help


<aura:component >

    <aura:attribute name="item" type="Camping_Item__c" required="true"/>
    <aura:attribute name="buttonDisabled" type="String" default="false"/>

    <p>Price:
        <ui:outputCurrency value="{!v.item.Price__c}"/>
    </p>
    <p>Name:
        <ui:outputText  value="{!v.item.Name}"/>
    </p>
    <p>Quantity:
        <ui:outputNumber value="{!v.item.Quantity__c}"/>
    </p>
    <p>Packed?:
        <ui:outputCheckbox value="{!v.item.Packed__c}"/>
    </p>
    
    <ui:button label="Packed!" press="{!c.packItem}" disabled="{! v.buttonDisabled}" />
    
</aura:component>

({
    packItem : function(component, event, helper) {
        component.set("v.item", { 'sobjectType': 'Camping_Item__c','Packed__c': true });
        component.set("v.buttonDisabled", "true");  
    }
})

 
I'm going through this trail and I have gotten stuck on the Handle acitons with controllers module in the first section in the intermeidate developer trail. I am stuck onthe chalange for this module. The error i have not been able to get past is this: The campingListItem Lightning Component doesn't contain a button or its attributes are not set correctly when clicked.
I know the code i have now is not perfect, i have been messing with it trying everything i can think of for hours now. at this point this is what i have:
<aura:component >
    <aura:attribute name="item" type="Camping_Item__c" />
  
     <aura:attribute name="buttonDisabled" type="String" default="false"/>
   
    <ui:outputText value="{! v.item.name}"  />
     <ui:outputCheckbox value="{!v.item.Packed__c}"/>
     <ui:outputCurrency value="{!v.item.Price__c}"/>
     <ui:outputNumber value="{! v.item.Quantity__c}"  />
    <ui:button  label="Mark as packed" press="{!c.packItem}" disabled="{! v.buttonDisabled}" />
     
</aura:component>


and JS of
({
 packItem  : function(component, event, helper) {
      //component.set("v.item.Packed__c", true);      
       
       component.set("v.buttonDisabled", "true");         
 }
})


the one line is commented out because i was trying to just focus and get past this one error.
I just can't seem to figure out how the challenge want me to disable the button. very frustrating when the module doesn't give an example of how to do this and the challenge expects you to figure it out. I've looked at all the additional resources for the module and looked in forms and google, and i guess this is my last hope. otherwise I guess I'll have to skip this challenge...
Thanks for any help.