I initialized tinyMCE as follows:
$('#text').tinymce({
// Location of TinyMCE script, optional, already loaded in page.
script_url : '../adminContent/js/tiny_mce/tiny_mce.js',
// General options
theme : "advanced",
plugins : "table,advimage,advlink,iespell,inlinepopups,preview,contextmenu,paste,visualchars",
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,forecolor,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,removeformat,cleanup,code,|,preview,tablecontrols,|,hr,visualaid,|,charmap,iespell",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true
});
The code above works fine. The problem is that I'm trying to remove tinyMCE.
My removal code:
$('#text').tinymce().execCommand('mceRemoveControl', false, 'text');
I also tried:
$('#text').remove();
and
$('#text').tinymce().remove();
The first seems to do nothing. The last two give me this error:
Unprepared ReferenceError: t undefined
Although tinymce is loaded with an HTML document, I load another script using:
$.getScript(viewPath + '/mod/adminContent/js/editContent.js', function(){
initEditContent(popup);
});
popup is a link to the popup window into which tinymce is loaded. This is just a div created using jquery. The content of the div is loaded using jquery ajax.
editContent.js looks like this:
var contentID;
function initEditContent(popup){
contentID = $('#contentID').val();
tinyMCE.execCommand("mceAddControl", true, 'text');
setTimeout(reposition, 50);
setTimeout(reposition, 150);
setTimeout(reposition, 250);
$('#editTextForm').ajaxForm(
{
beforeSubmit: function(){
},
success: function(responseText){
tinyMCE.execCommand("mceRemoveControl", true, 'text');
$('#' + contentID).html(responseText);
}
});
}