Last active
February 6, 2018 11:54
-
-
Save itsmebasti/1088f49e96e0ce57d18bea61465fa9bf to your computer and use it in GitHub Desktop.
Reference Change Handlers in Lightning
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:referenceTest /> | |
</aura:application> |
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 > | |
<aura:attribute name="value1" type="Decimal" /> | |
<aura:attribute name="value2" type="Decimal" /> | |
<aura:attribute name="valueList" type="Decimal[]" /> | |
<aura:attribute name="referencedList" type="Decimal[]" /> | |
<aura:attribute name="listWithReferences" type="Decimal[]" /> | |
<aura:handler name="init" value="{!this}" action="{!c.initialize}" /> | |
<aura:handler name="change" value="{!v.value1}" action="{!c.printEventExpression}" /> | |
<aura:handler name="change" value="{!v.value2}" action="{!c.printEventExpression}" /> | |
<aura:handler name="change" value="{!v.valueList}" action="{!c.printEventExpression}" /> | |
<aura:handler name="change" value="{!v.referencedList}" action="{!c.printEventExpression}" /> | |
<aura:handler name="change" value="{!v.listWithReferences}" action="{!c.printEventExpression}" /> | |
<lightning:input aura:id="input" value="{!v.value1}" type="number" variant="label-hidden" label="Value" /> | |
<lightning:input aura:id="input" value="{!v.value2}" type="number" variant="label-hidden" label="Value" /> | |
</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
({ | |
initialize: function(cmp, evt, helper) { | |
var values = [1,2]; | |
cmp.set("v.valueList", values); | |
cmp.set("v.value1", cmp.getReference("v.valueList.0")); | |
cmp.set("v.value2", cmp.getReference("v.valueList.1")); | |
cmp.set("v.referencedList", cmp.getReference("v.valueList")); | |
cmp.set("v.listWithReferences", [cmp.getReference("v.valueList.0"), | |
cmp.getReference("v.valueList.1")]); | |
}, | |
printEventExpression: function(cmp, evt, helper) { | |
console.log(evt.getParam("expression")); | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
listWithReferences
seems not to fire a change event.