Insert saved text in the editor

I save the typed text in the editor in the database
For example, the user typed

Hi . are you well. I'm testing the editor

When I save this, it is stored like this
     <div>
       <p> </p><p>Hi . are you well. I'm testing the editor</p>
      </div>


Now when I put it in the editor with the following code (jQuery)

 var editor= document.getElementById('MyEditor').ej2_instances[0];
  editor= .setHtml = "@ViewBag.editiLetter.Letter_text";


The tags also show that I do not want the tags to be displayed and the text must be displayed as text typed by the user

1 Reply 1 reply marked as answer

IS Indrajith Srinivasan Syncfusion Team December 31, 2020 11:50 AM UTC

Hi Yeadam, 
 
Greetings from Syncfusion support, 
 
We have validated your reported query. Instead of manipulating the HTML element and set the HTML content, we suggest you use the value property of the Rich Text Editor. Check the below code blocks and sample for reference. 
 
 
<button id="testBtn">Display Value</button> 
    <ejs-richtexteditor id="rteID"> 
    </ejs-richtexteditor> 
<br/> 
<br/> 
 
<p id="rteValue"></p> 
 
<script> 
    document.getElementById('testBtn').addEventListener('click', function () { 
        var editor = document.getElementById('rteID').ej2_instances[0]; 
        // Adding the DB saved value in the editor. 
        editor.value = "<div><p> </p><p>Hi . are you well. I'm testing the editor</p></div>";         
    }); 
</script> 
 
 
 
In addition, below are the following ways to retrieve the formatted content from the editor. 
 
 
Can you please check the above sample and let us know if it meets your requirements ? 
 
Regards, 
Indrajith 


Marked as answer
Loader.
Up arrow icon