function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jack daniel 16Jack daniel 16 

How to use onChange on Lighting InputrRchText

Best Answer chosen by Jack daniel 16
Ajay K DubediAjay K Dubedi
Hi Jack,

You can use the below Code.

<<<<---Lightning Component----->>>
 
<aura:component >
    <aura:attribute name="myVal" type="String" />
    <aura:handler name="change" value="{!v.myVal}" action="{!c.handleValueChange}"/>
    <lightning:inputRichText value="{!v.myVal}" aura:id="grr"/>
</aura:component>

<<<<----Controller--->>>
({
    handleValueChange : function(c, e, h) {
        console.log('Get this value Here');
    }
})

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
 

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

You can use the aura:valueChange event. It indicates that an attribute value has changed. This event is automatically fired when an attribute value changes. The aura:valueChange event is handled by a client-side controller. A component can have multiple <aura:handler name="change"> tags to detect changes to different attributes.

https://developer.salesforce.com/docs/atlas.en-us.212.0.lightning.meta/lightning/ref_aura_valueChange.htm

Component:
<aura:component access="global" >
    <aura:attribute name="someVal" type="String" />
    <aura:handler name="change" value="{!v.someVal}" action="{!c.handleValueChange}"/>

    <lightning:inputRichText value="{!v.someVal}" aura:id="irt"/>
</aura:component>

Controller:
handleValueChange : function(component){
    console.log("Value -> " + component.get('v.someVal'));
}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Ajay K DubediAjay K Dubedi
Hi Jack,

You can use the below Code.

<<<<---Lightning Component----->>>
 
<aura:component >
    <aura:attribute name="myVal" type="String" />
    <aura:handler name="change" value="{!v.myVal}" action="{!c.handleValueChange}"/>
    <lightning:inputRichText value="{!v.myVal}" aura:id="grr"/>
</aura:component>

<<<<----Controller--->>>
({
    handleValueChange : function(c, e, h) {
        console.log('Get this value Here');
    }
})

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
 
This was selected as the best answer