Articles in this section
Category / Section

How to dynamically create RTE control and append it to DOM?

1 min read

Description

We can render the JavaScript Rich Text Editor control dynamically and append it to DOM element.

Solution

When we render the RTE in script, before appending it to DOM, the controls events will not bound until it is appended to DOM. Once we have appended the control to DOM, we need to refresh the control to bind the events.

Please refer the below code snippet:

 

<body>
<div class="control">
    </div>
<script type="text/javascript">
    $(document).ready(function () {
 
        var $txtarea = $('<textarea id="HTML" name="HTML" data-bcitem="edit" data-bcedit-type="text" tabindex="51" data-bind="HTML" data-changed="0" rows="12" style="height: 346px; width: 348px;"></textarea>');
 
        var $wrapper=$('<div id="wrapper" />');
 
        $txtarea.appendTo($wrapper);
 
        $txtarea.ejRTE();
 
        $wrapper.prependTo('.control');
 
        var obj = $("#HTML").data("ejRTE");
 
        obj.refresh();
 
    });
</script>
</body>

 

Conclusion

I hope you enjoyed learning about how to dynamically create Rich Text Editor control and append it to DOM.

You can refer to our JavaScript Rich Text Editor feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our JavaScript Rich Text Editor example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied