Skip to content
Advertisement

How do I remove tinyMCE and then re-add it?

I am trying to add the tinyMCE editor to my page, remove it, then add it again but am getting errors.

When I run Part A, then Part B, Than Part A again I get the error:

JavaScript

Part A

JavaScript

Part B

JavaScript

Edit:

Below is the full JavaScript function. The first time through it opens the dialog and works, the contents is in the editor and there is no error. When I click the close button, the dialog is closed. When I run the function again, the dialog displays but the editor is empty and there is the above error.

JavaScript

Advertisement

Answer

To cleanly remove an editor instance and avoid any errors use:

JavaScript

To reinitialize the instance use:

JavaScript

Be aware that when moving TinyMCE editors in the DOM you need to removeControl and addControl too, otherwise it results in JS errors.


As of TinyMCE 4 the methods to remove and reinitialize an instance are now…

To cleanly remove an editor instance and avoid any errors use:

JavaScript

To reinitialize the instance use:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement