gpt4 book ai didi

jquery - 完全删除 JQuery tinyMCE

转载 作者:行者123 更新时间:2023-12-03 23:04:43 27 4
gpt4 key购买 nike

我已经像这样初始化了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
});

上面的代码完美运行。问题是当我尝试删除tinyMCE时。

我的删除代码是:

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

我也尝试过:

$('#text').remove();

$('#text').tinymce().remove();

第一个似乎没有做任何事情。最后两个给我这个错误:

Uncaught ReferenceError: t is not defined

虽然tinymce是由HTML文档加载的,但我正在使用以下方式加载另一个脚本:

$.getScript(viewPath + '/mod/adminContent/js/editContent.js', function(){
initEditContent(popup);
});

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" />&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);
}
});
}

最佳答案

这看起来像是自 3.5b3 版本以来tinyMCE 的问题。它适用于版本 3.5b2。

参见my fiddle示例。

您会注意到它加载和卸载正常。但是将版本更改为edge或3.5b3,卸载时就会出现错误。

tinyMCE bug site 上所述:

Description of problem:

Javascript error on line 13518. t is not defined.

Steps to reproduce:

  1. Call tinyMCE.execCommand('mceRemoveControl', false, idOfTextarea);

Problem:

In 3.5b3 you renamed t to self, but didn't rename the used variable in the same line to get the doc.

Solution:

Change line 13518 (in function hide()) to: var self = this, doc = self.getDoc();

关于jquery - 完全删除 JQuery tinyMCE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10073625/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com