12

I am trying to use "lightning:input" components (still in beta) but I encounter an issue when the component is firing the onchange event :

Something has gone wrong. Underlying raw object [object Object] does not support property: currentTarget
Failing descriptor: {c$testComponents$controller$sayHello}.
Please try again.

cmp

<lightning:input type="text" value="test" name="inputText" label="Input" onchange="{!c.sayHello}"/>

controller

sayHello : function(component, event, helper) {
    alert('Hello');
}

Does anyone have a workaround which works with this component ?

Thank you !

1
  • Were you ever able to figure this out? I'm running into the exact same issue with "lightning:textArea".
    – Trent
    Oct 19 '16 at 19:12
12

Thanks for bringing this up. This is a known problem that is currently being worked on. In the meantime, you can work around the issue by binding a change handler to the value attribute:

<aura:attribute name="value" type="String" />
<aura:handler name="change" value="{!v.value}" action="{!c.onValueChange}" />
<lightning:input type="text" value="{!v.value}" />
4
  • Thank you Eugene. ( I'm sad we don't have an updateOn attribute anymore because this workaround is only working with keyup events on text inputs...) Do you you have a link where we can track the fix for this ? Oct 25 '16 at 17:07
  • Hey Lucas--what use case is this workaround not working for? Oct 25 '16 at 23:29
  • If I want my action to only be triggered on blur instead of keyup with input text for example Oct 26 '16 at 15:40
  • This Doesn't work if your lightning:input tag is inside aura:iteration@EugeneKashida
    – Saran Dev
    Oct 11 '17 at 11:14
2

I have faced some errors before too and I find it generally easier to work with event.getSource() which returns the input component. On it you can use the usual get method on components:

<lightning:input type="text"
                 value="{!v.value}"
                 name="inputName"
                 onchange="{! c.onChange }" />
onChange: function(component, event, helper) {
    const inputName = event.getSource().get('v.name');
    const inputValue = event.getSource().get('v.value');
    // ...
}

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.