Problems updating AJAX and TinyMCE

So, I came across this predicament.

<SCRIPT src="../js/tiny_mce/tiny_mce.js"></script> <SCRIPT type="text/javascript"> tinyMCE.init({ mode : "textareas", theme : "simple" }); </SCRIPT> <SCRIPT src="../js/admin.js"></script> 

The above is being called on my PHP page.

Then i call

 var request = $.ajax( { url:"getEvents.php", type:"POST", data:{'method':'showevents'}, dataType:"html" }).done(function(msg){ $('#eventlistbody').html(msg); }); setTimeout( function(){ $(".mceSimple").each(function(){ tinyMCE.execCommand("mceAddControl",false, this.id); }) },2000); 

this loads a bunch of text areas ..... tinyMCE will load into all text areas the first time it returns. When I click on reboot, which starts above again, and returns the text areas, they no longer have a tiny MCE attached to them. I am not sure why it works for the first time, and not at subsequent times.

+6
source share
3 answers

Before rebooting, you must close tinymce correctly in order to be able to reinitialize the tinymce editor after the reboot has been done. This is necessary because tinymce does not like being dragged around the house. And the initialized instances of the editor can have one unique identifier (using reload will force tinymce to try to initialize the second editor with the same identifier that will fail).

Tinymce3: To close the edtor instance, follow these steps:

 tinymce.execCommand('mceRemoveControl',true, editor_id); 

To reinitialize use

 tinymce.execCommand('mceAddControl',true, editor_id); 

Tinymce4: To close the edtor instance, follow these steps:

 tinymce.execCommand('mceRemoveEditor',true,editor_id); 

To reinitialize use

 tinymce.execCommand('mceAddEditor',true,editor_id); 
+12
source

TinyMCE.remove (editor_id) works for me.

+2
source

Tinymce4: To close the edtor instance, use:

 tinymce.remove(); 

or specify one unique identifier

 tinymce.execCommand('mceRemoveEditor',true,editor_id); 

To reinitialize use

 tinymce.init(conftinymce); 

or specify one unique identifier

 tinymce.execCommand('mceAddEditor',true,editor_id); 
0
source

All Articles