Having trouble getting help?
Contact Support
Contact Support
Integrating Rich Text Editor in Dialog Control
21 Mar 20251 minute to read
When rendering the Rich Text Editor inside a Dialog Control, the dialog container and its wrapper elements are initially styled with display: none
. This styling prevents the editor’s toolbar from calculating the proper offset width. As a result, the toolbar may render incorrectly, appearing above the edit area container.
To resolve this issue, we can utilize the refreshUI
method of the Rich Text Editor in conjunction with the open event. This approach ensures that the Rich Text Editor’s UI is properly refreshed and rendered once the Dialog is visible.
<ejs-button id="targetButton" e-ripple="true" content="OPEN DIALOG"></ejs-button>
<ejs-dialog id="dialog" height="350px" width="400px" header="Dialog Header"
showCloseIcon="true" footerTemplate="Dialog Footer" open="onOpen">
<e-content-template>
<ejs-richtexteditor id="RTE"></ejs-richtexteditor>
</e-content-template>
</ejs-dialog>
<script>
document.getElementById('targetButton').onclick = function () {
var dialogObj = document.getElementById('dialog').ej2_instances[0];
dialogObj.show();
};
function onOpen(args){
var rteObj = document.getElementById('RTE').ej2_instances[0];
rteObj.refreshUI()
}
</script>
<style>
body, html {
width: 100%;
height: 100%;
}
</style>
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}