Forum Replies Created

Viewing 1 of 1 posts
  • Eswar Kumar

    Member
    November 29, 2018 at 4:37 pm

    Try this , It will be easy for you all to complete the challange.

    Step1:

    In the "campingListItem.cmp" paste this code  (ignore '' :P)

    <aura:component >
        <aura:attribute name=”item” type=”Camping_Item__c” required=”true”/>
        <p>Name:
            <ui:outputText value = “{!v.item.Name}”/>
        </p>
        <p>Price:
            <lightning:formattedNumber value=”{!v.item.Price__c}” style=”currency”/>
        </p>
        <p>Quantity:
            <lightning:formattedNumber value=”{!v.item.Quantity__c}” style=”number”/>
        </p>
        <p>Packed:
            <lightning:input type=”toggle” label=”Packed?” checked=”{!v.item.Packed__c}”/>
        </p>
        <div>
            <lightning:button label=”Packed!” onClick=”{!c.packItem}”/>
        </div>
    </aura:component>

    Step2:

    create a controller to write the javascript code. ie campingListItemController.js and campingListController.js

    Step3:

    In campingListController.js, paste this code

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

    Step4: In "campingListItemController.js" Paste This Code

    ({
        packItem : function(component, event, helper)
        {
            var checkbox = component.get("v.item",true);
            checkbox.Packed__c= true;
            component.set("v.item",checkbox);
            event.getSource().set('v.disabled',true);
        }
    })

    Now you can save them and check Challange. It will pass 100%.

    Thanks you,
    Eshu

Viewing 1 of 1 posts

Popular Salesforce Blogs

Popular Salesforce Videos