Using Rich Text Editor in a Dialog Control
When using a Rich Text Editor in a Dialog Control, there are a few considerations:
- The editor and the elements it creates (particularly the floating properties palettes) need to be rendered into the Dialog's DOM structure. If the Dialog is modal, it will try to maintain focus within its DOM confines, so ensuring that all editor elements are children of the Dialog's DOM is crucial.
- The most common way to submit a Dialog's form contents is asynchronously using Connection Manager. This means that editor cannot automatically attach itself to the form's
submit
event. Instead, we need to call the editor's saveHTML
method prior to executing the Dialog's submit
method.
- The Rich Text Editor needs special handling when it is hidden (ie, when a parent element is set to
display:none
). Dialogs, of course, are usually hidden by default and appear only in response to user action. As a result, we need to listen for the Dialog's showEvent
and hideEvent
and prepare the Rich Text Editor to recover gracefully when the Dialog is hidden from view.
These three considerations are each accounted for in the code below, which is fully commented and represents the full JavaScript source for this implementation: