imperium2335
imperium2335

Reputation: 24112

Remove TinyMCE for new data, then reinitialise

I have a textarea that has tinyMCE applied to it when the dialog is opened (dialog from JQuery UI).

The problem comes when a user wants to edit a record description that is different to a record they previously edited. When the dialog loads I need it to clear everything in the textarea from before and insert the new text from AJAX.

Basically, I initialise TinyMCE on the textarea when the dialog opens. I then want TinyMCE to be destroyed so I can clear all inputs and textareas when the dialog is closed.

How can this be done? I have tried .remove() and .destroy on the TinyMCE object but it either does nothing or causes an error.


I have tried:

tinyMCE.execCommand("mceRemoveControl", false, 'textarea_id');

But that doesn't work either :(

Upvotes: 1

Views: 1129

Answers (1)

Thariama
Thariama

Reputation: 50832

To shut down an editor instance correctly use:

tinyMCE.execCommand("mceRemoveControl", false, 'textarea_id');

This is necessary when you move the editor around inside the dom or when you remove parts of the dom containing the editor iframe.

To reinit this unique editor instance use

tinyMCE.execCommand("mceAddControl", false, 'textarea_id');

Upvotes: 2

Related Questions