I have the following component:

<aura:component implements="force:hasRecordId,flexipage:availableForAllPageTypes,force:lightningQuickActionWithoutHeader" 
                access="global" >
    <input type="text" name="Name" class="slds-input" value="Test" onChange="{!c.doSomething}"/>


    doSomething : function(component, event, helper) {

When i change the value of the input, "doSomething" is not triggered. the html looks like this:

<div data-aura-rendered-by="420:0" class="flexipageComponent" data-aura-class="flexipageComponent">
             <input class="slds-input" type="text" name="Name" data-aura-rendered-by="424:0"> 

looks like onChange is not even rendered, what am i doing wrong?

  • I think there is a typo, onchange 'c' is in small case, can you try that? – Pranay Jaiswal Jan 2 '19 at 9:49
  • it didn't work :( – Dana Griff Jan 2 '19 at 9:52
  • Hi Dana, I tried same code with onchange in small case and it worked. Yes it was not rendered in html because lightning remove and minifies it into a seperate JS file – Pranay Jaiswal Jan 2 '19 at 9:56
  • i had a typo, you are correct. im sorry will delete this question – Dana Griff Jan 2 '19 at 9:59
  • Keep it as it is.. It would help, other in case they searched – Pranay Jaiswal Jan 2 '19 at 9:59

onchange actually is all in small-case. So your code will be

 <input type="text" name="Name" class="slds-input" value="Test" onchange="{!c.doSomething}"/>

Also, You could not find onchange in rendered dom as lightning locker minifies and moves the JS in a different file so that it cant be altered easily.

src: https://www.w3schools.com/jsref/event_onchange.asp

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.