Remove jQuery tinyMCE completely

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);

    // Submit form
    $('#editTextForm').ajaxForm(
    {
        // Before submit
        beforeSubmit: function(){
            //setPopupMessage(popup, '<div id="loading"><img src="../../img/loading.gif" />&nbsp;Please wait...</div>');
        },

        // Once submit completed
        success: function(responseText){
            tinyMCE.execCommand("mceRemoveControl", true, 'text');
            //closePopup(popup);

            // Update button with new data
            $('#' + contentID).html(responseText);
        }
    });
}
+5
source share
3 answers

This looks like a problem with tinyMCE from version 3.5b3. It works in version 3.5b2.

See an example of my violin .

, . 3.5b3, .

- tinyMCE:

:

JavaScript 13518. t .

:

  • tinyMCE.execCommand('mceRemoveControl', false, idOfTextarea);

3.5b3 t self, , .

13518 ( hide()) : var self = this, doc = self.getDoc();

+4

. , , tinyMCE HTML-, , , :

tinyMCE.init({
    mode : "textareas",
    // 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,

    oninit: function(){
        alert('tinyMCE loaded');
    }
});

, tinyMCE. , :

tinyMCE.remove('text');
+1

$('#text').tinymce().execCommand('mceRemoveControl', true, 'text');

"" -

<textarea id='text' .....
0

All Articles