-
Notifications
You must be signed in to change notification settings - Fork 11
/
Handling actions with controllers
41 lines (32 loc) · 1.12 KB
/
Handling actions with controllers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
1.campingListItem.cmp
<aura:component >
<aura:attribute name="item" type="Camping_Item__c" required="true"/>
//refer object fields API for each fields given
<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>
<lightning:input type="toggle"
label="Packed?"
name="packed"
checked="{!v.item.Packed__c}" />
</p>
<p>
<lightning:button label="Packed!"
onClick="{!c.packItem}"/>
</p>
</aura:component>
2.campingListItemController.js
({
packItem: function(component, event, helper) {
var a = component.get("v.item",true);
a.Packed__c = true;
component.set("v.item",a);
var btnClicked = event.getSource();
btnClicked.set("v.disabled",true);
}
})