gpt4 book ai didi

jquery - TinyMCE + jQuery + 自定义插件 = tinymce 未定义?

转载 作者:行者123 更新时间:2023-12-01 05:09:31 25 4
gpt4 key购买 nike

当我尝试创建小插件以允许我在网站中的所有文本区域上打开和关闭所见即所得时,就会出现问题。

//$('form.default textarea').each(function(){
// console.log( $('<a href="#">Enable WYSIWYG editor</a>').insertAfter('form.default textarea').prev('textarea.wysiwyg').tinymce().hide() );
//});

完整的(稍微简化的)代码如下所示:

$('textarea.wysiwyg').tinymce({
skin : 'cirkuit',
theme : 'advanced',
plugins : 'pagebreak,style,layer,advlink,inlinepopups,contextmenu,paste,directionality,noneditable,nonbreaking,xhtmlxtras,template',
// Theme options
theme_advanced_buttons1 : 'formatselect,fontsizeselect,forecolor,|,bold,italic,strikethrough,|,bullist,numlist,|,justifyleft,justifycenter,justifyright,|,link,unlink,|,image,|,code,paste,pastetext,pasteword,removeformat,|,backcolor,|,underline,justifyfull,sup,|,outdent,indent,|,hr,charmap,|,undo,redo',
theme_advanced_buttons2 : '',
theme_advanced_buttons3 : '',
theme_advanced_toolbar_location : 'top',
theme_advanced_toolbar_align : 'left',
theme_advanced_statusbar_location: 'bottom',
theme_advanced_resizing : true,
theme_advanced_resize_horizontal : false,
height : 500,
theme_advanced_resizing_min_height : 500,
document_base_url : 'http://static.<?=$settings['system_host']?>/'
});

$('textarea.wysiwyg').each(function() {
$(this).tinymce().hide();
});

错误是什么? FireBug 表示 tinymce() 处于未定义状态;此消息出现在each() 循环中。这样,tinymce()实际上就被初始化了。

我真的很迷茫,不知道是什么原因造成的。

最佳答案

这是您正在寻找的切换功能:http://tinymce.moxiecode.com/punbb/viewtopic.php?id=436

var tinyMCEmode = true;
function toogleEditorMode(sEditorID) {
try {
if(tinyMCEmode) {
tinyMCE.removeMCEControl(tinyMCE.getEditorId(sEditorID));
tinyMCEmode = false;
} else {
tinyMCE.addMCEControl(document.getElementById('pagecontent'), sEditorID);
tinyMCEmode = true;
}
} catch(e) {
//error handling
}
}

使用:

<a href="#" title="toogle TinyMCE" onclick="toogleEditorMode('pagecontent');">Toogle TinyMCE</a>

我怀疑你的问题是当tinyMCE使用它自己的JavaScript库时使用jQuery来执行此操作。它显然不喜欢隐藏。我会使用类似于给出的示例的东西,因为我们知道它有效。

关于jquery - TinyMCE + jQuery + 自定义插件 = tinymce 未定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3057332/

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