0

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}"/>
</aura:component>

Controller:

({
    doSomething : function(component, event, helper) {
        console.log('test');
    }
})

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

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

6
  • I think there is a typo, onchange 'c' is in small case, can you try that? Commented Jan 2, 2019 at 9:49
  • it didn't work :(
    – Dana Griff
    Commented Jan 2, 2019 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 Commented Jan 2, 2019 at 9:56
  • i had a typo, you are correct. im sorry will delete this question
    – Dana Griff
    Commented Jan 2, 2019 at 9:59
  • Keep it as it is.. It would help, other in case they searched Commented Jan 2, 2019 at 9:59

1 Answer 1

0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .