Thursday, September 6, 2018

Change Event in Salesforce Lightning

 The change method is called when the value in one of the attribute changes.
As an Example If i am having  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 you change value in input box "enter text" alert will be shown.

Change Event in Salesforce Lightning,Lightning Change Event,aura:handler name="change",aura:value Change,lightning events.


No comments:

Post a Comment