我已经像这样初始化了tinyMCE:
$('#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
});
Run Code Online (Sandbox Code Playgroud)
上面的代码非常有效.问题是当我尝试删除tinyMCE时.
我的删除代码是:
$('#text').tinymce().execCommand('mceRemoveControl', false, 'text');
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
$('#text').remove();
Run Code Online (Sandbox Code Playgroud)
和
$('#text').tinymce().remove();
Run Code Online (Sandbox Code Playgroud)
第一个似乎没有做任何事情.最后两个给我这个错误:
未捕获的ReferenceError:未定义t
虽然通过HTML文档加载了tinymce,但我正在使用以下命令加载另一个脚本:
$.getScript(viewPath + '/mod/adminContent/js/editContent.js', function(){
initEditContent(popup);
});
Run Code Online (Sandbox Code Playgroud)
popup是对加载了tinymce的弹出窗口的引用.它只是一个使用jquery创建的div.div的内容使用jquery ajax加载.
editContent.js看起来像这样:
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" /> Please wait...</div>');
},
// Once submit completed
success: function(responseText){
tinyMCE.execCommand("mceRemoveControl", true, 'text');
//closePopup(popup);
// Update button with new data
$('#' + contentID).html(responseText);
}
});
}
Run Code Online (Sandbox Code Playgroud)
尝试
$('#text').tinymce().execCommand('mceRemoveControl', true, 'text');
Run Code Online (Sandbox Code Playgroud)
其中“text”是您的编辑器的 ID
<textarea id='text' .....
Run Code Online (Sandbox Code Playgroud)