Last active
June 21, 2018 16:43
-
-
Save sfdcevnagel/36ebd902b2c644f98972857a345083dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" > | |
<!-- item attribute is an instance of Camping_Item__c--> | |
<aura:attribute name="item" type="Camping_Item__c" description="instance of Camping_Item__c object" required="true" default="{Packed__c : false}" access="global"/> | |
<p> | |
Name: {!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}"/> | |
</p> | |
<p> | |
<lightning:input type="toggle" | |
label="Packed ?" | |
name="Packed" | |
checked="{!v.item.Packed__c}" /> | |
</p> | |
<lightning:button label="Packed!" | |
onclick="{!c.packItem}"/> | |
</aura:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
packItem : function(component, event, helper) { | |
//set the Packed__c property of the item (instance of Camping_Item__c) attribute | |
component.set("v.item.Packed__c",true); | |
//event.getSource refers the source tag from the event has invoked. | |
//set the disabled attribute to true | |
event.getSource().set("v.disabled",true); | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:application extends="force:slds"> | |
<c:campingListItem item="{Price__c: 100, Packed__c: false, Quantity__c: 10, Name:'Test'}" /> | |
</aura:application> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment