Skip to content

Instantly share code, notes, and snippets.

@sfdcevnagel
Last active June 21, 2018 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfdcevnagel/36ebd902b2c644f98972857a345083dc to your computer and use it in GitHub Desktop.
Save sfdcevnagel/36ebd902b2c644f98972857a345083dc to your computer and use it in GitHub Desktop.
<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>
({
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);
}
})
<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