3

I can initialize the value of a lightning:input by doing this:

Component:

<lightning:input aura:id="subject" type="text" label="Subject" name="subject" />

Controller:

component.find("subject").set("v.value", "Hello!");

Result:

enter image description here


However, with lightning:inputRichText, when I follow the same pattern, the UI does not show the value, but if I alert(component.find("body").get("v.value")), it shows the expected value.

Component:

<lightning:inputRichText aura:id="body" />

Controller:

component.find("body").set("v.value", "<p>This will be init properly once I switch to ContentNote</p>");

Result:

enter image description here

Can anyone point me in the right direction with this? At the moment, the component documentation doesn't have anything relevant besides listing value as an attribute.

2

The below code worked perfectly fine for me

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
 <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
 <lightning:inputRichText aura:id="body" />
</aura:component>

Controller code is as below

  ({
     doInit : function(component, event, helper) {
       component.find("body").set("v.value", "<p>This will be init properly once I switch to ContentNote</p>");
     }
 })

enter image description here

  • 1
    Hm - you're right. I added the component.find("body").set to the init method and it worked just fine. For some reason, it breaks when I have it in a separate method that's called from the parent component, using aura:method....anyway, that is a separate question, and you definitely answered the one that's posted here. I'm going to post a separate question for the specific case that you've helped me narrow it down to. – Brian Mansfield Mar 23 '17 at 14:07
  • for placement of the update in another method see this answer: salesforce.stackexchange.com/questions/165758/… – Bryan Jun 12 '18 at 0:35

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.