I have a few lightning components already written and those use <lightning:x />
markup.
I am still not able to use event.getSource()
instead of an aura:id
in scenario where I do an aura:iteration
and can not set a dynamic aura:id
.
e.g.:
component.cmp
<aura:iteration items="{! v.items }" var="item">
<lightning:input
type="checkbox"
onchange="{! c.onChange }"
name="{! item.name }
label="{! item.name }"
/>
</aura:iteration>
Controller.js
onChange: function(component, event, helper) {
const checkbox = event.getSource(); //getSource is not a function
}
Everywhere I can read answers saying that we should use id
to create dynamic ids but with the lockerservice (14th June) we will not be able to use those kind of tricks (same as event.target.value
).
Why this function does never work ?