Problem with lightning:input component. Onchange event

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 !

Answer

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}" />

Attribution
Source : Link , Question Author : Lucas Ennouchi , Answer Author : Eugene Kashida

Leave a Comment