Friday, September 7, 2018

aura:handler change in Salesforce Lightning

The change method is called when the value in one of the attribute changes.
As an Example If I am having  an attribute " Anyname", on change of attribute "Anyname" if I want to call javascript method I can do this as:


<aura:attribute name="Anyname" type="String" />
<aura:handler  name="change" value="{!v.Anyname}" action="{!c.doinit}"/>

Step 1: Build a lightning component.

<aura:component >  

<aura:attribute name="Anyname" type="String" default="text1" />
<aura:handler  name="change" value="{!v.Anyname}" action="{!c.doinit1}"/>
    <lightning:input name="enter text" value="{!v.Anyname}"/>


Step 2: Build a javascript controller.


    doinit1: function(component,event,helper){
        alert("Value change noticed");    


Note: Whenever we change the value in the input box "enter text", an alert "Value change noticed" will popup.

1 comment: