3

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 ?

3

With locker services enabled, this will work from Spring 17, which I guess is already deployed to some editions.

Find the documentation here.

Similar question was answered here.

| improve this answer | |
1

Your issue is similar to the one reported here Locker Service: How to get the event target? We are working on a fix for this. W-3458193 is the work item with R&D, if you want to reference in your salesforce case.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.