2
votes

I am loading an html via ajax but the html contains a tinyMCE editor by calling wp_editor. The problem is I can't switch to different view like from Text to Visual view. I am also unable to Insert media into the editor due to the same javascript error problem. Here's the javascript error upon clicking the Visual View: https://www.dropbox.com/s/s031ewzlez9hepn/screenshot-1.png

I tried a different approach by converting the textarea into tinyMCE directly by instantiating the execCommand() after the HTML has been loaded but it doesn't look like the WP tinyMCE editor. See image: https://www.dropbox.com/s/2waoywdubgme8mh/screenshot-2.png

1
+1 for the screenshots - Thariama

1 Answers

0
votes

The toggle between text / visual view is handled via QuickTags; When I clone, or load an editor instance via ajax I usually loop across the dom and find the ID of the editor instance I've just created and do something like the following;

var ed_id = $(this).find('textarea').attr('id');//find your editors textarea id             
tinymce.init(tinyMCEPreInit.mceInit[ed_id]);//init tinymce
quicktags({id : ed_id});//init quicktags

Usually works a treat.