Note that there are some explanatory texts on larger screens.

plurals
  1. POTinyMCE - dynamic add/remove multiple times
    text
    copied!<p>I'm working on some web application that uses tinyMCE. I use regular (non-jQuery version) of TinyMCE 3, but I use jQuery to add and remove it from the textarea.</p> <p>The textarea itself is populated first by html from the div, and then the tinymce control is added. (later that content is either saved to db or discarded by a form submit.</p> <p>Now - this all basically works, but problem I have is that once tinyMCE is added, and then removed once, it's stuck, and won't add the control a second time.</p> <p>I use this to load the tinyMCE</p> <pre><code>$(".mcmsmdl_pagestatic_editpopup").on('click',function(){ var smi = $(this).data('sectionmoduleindex'); var content = $('#mcmsmdl_pagestatic_content_'+smi).html(); $('#popup_module_pagestatic').data('sectionmoduleindex',smi); $('#mcmsmdl_pagestatic_content_textarea').val(content); tinyMCE.execCommand('mceAddControl', false, 'mcmsmdl_pagestatic_content_textarea'); displayPopup('module_pagestatic',true); }); </code></pre> <p>Note: displayPopup() is a function to just show the container that holds the form with tinyMce.</p> <p>The tinyMce is removed on popup closing with:</p> <pre><code>$(".popup_shadow_module_pagestatic").on('click',function(event){ event.preventDefault(); tinyMCE.execCommand('mceFocus', false, 'mcmsmdl_pagestatic_content_textarea'); tinyMCE.execCommand('mceRemoveControl', false, 'mcmsmdl_pagestatic_content_textarea'); displayPopup('module_pagestatic',false); }); </code></pre> <p>I checked - and it is unloaded after the second code. Any ideas why won't it re-add the tinyMCE control when calling the same (first) code again?</p> <p><strong>EDIT:</strong> After checking with console: It's indeed loaded and unloaded correctly, but second loading produces a "Too much recursion" error. It seems that somewhere in tinyMCE code it goes in an infinite loop...</p> <p><strong>EDIT2</strong> As Thariama suggested, I changed the code to first display the textarea and then add the control, and now I get different errors:</p> <p>in tinymce.js:</p> <blockquote> <p>TypeError: this.getDoc(...) is undefined</p> </blockquote> <p>in editor_plugin.js:</p> <blockquote> <p>NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)[nsIDOMNavigator.userAgent]</p> </blockquote> <p><strong>EDIT3</strong> Errors from edit2 were because the page was refreshed, and not loaded clean. When loaded clean, the Too Much Recursion error is shown again...</p> <p><strong>EDIT4</strong> All the problems seem to be fixed by removing the iBrowser plugin. - now I need to find another free image uploader... :(</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload