【发布时间】:2012-04-25 14:51:31
【问题描述】:
我有一个 jquery UI 对话框,里面有 tinymce,我第一次打开对话框时 tinymce 工作正常,但是一旦我关闭对话框并重新打开它,我会看到 tinymce 编辑器,但我无法在里面输入任何内容好像它被禁用了一样。
【问题讨论】:
-
请附上您的代码...我的水晶球今天正在播放...
标签: jquery jquery-ui tinymce jquery-dialog
我有一个 jquery UI 对话框,里面有 tinymce,我第一次打开对话框时 tinymce 工作正常,但是一旦我关闭对话框并重新打开它,我会看到 tinymce 编辑器,但我无法在里面输入任何内容好像它被禁用了一样。
【问题讨论】:
标签: jquery jquery-ui tinymce jquery-dialog
这里的问题看起来很清楚。关闭 jQuery 对话框时,您没有正确关闭 tinymce 实例。
要关闭编辑器实例,请使用:
tinymce.execCommand('mceRemoveControl',true,'editor_id');
更新:您应该使用 document.ready - 函数不会延迟编辑器初始化太多(如果文档在 1.4 秒后加载 - 您会破坏 1.6 秒并保持用户等待):
$(document).ready(function() {
g = {};
g.oEditor = new tinymce.Editor (
"notesComments",
{
// General options
mode : "none",
theme : "advanced",
height : 350,
plugins : "style,layer,table,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
// Theme options
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull",
theme_advanced_buttons2 : "formatselect,fontselect,fontsizeselect",
theme_advanced_buttons3 : "undo,redo,|,sub,sup,|,charmap,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen|,nonbreaking,pagebreak,hr",
theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote",
theme_advanced_buttons5 : "link,unlink,image,cleanup,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons6 : "tablecontrols,|,removeformat,visualaid",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false
});
g.oEditor.render();
});
【讨论】:
我已经通过延迟函数解决了这个问题:
setTimeout(function() {
g = {};
g.oEditor = new tinymce.Editor (
"notesComments",
{
// General options
mode : "none",
theme : "advanced",
height : 350,
plugins : "style,layer,table,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
// Theme options
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull",
theme_advanced_buttons2 : "formatselect,fontselect,fontsizeselect",
theme_advanced_buttons3 : "undo,redo,|,sub,sup,|,charmap,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen|,nonbreaking,pagebreak,hr",
theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote",
theme_advanced_buttons5 : "link,unlink,image,cleanup,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons6 : "tablecontrols,|,removeformat,visualaid",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false
});
g.oEditor.render();
}, 3000);
【讨论】:
这个就像一个魅力:
if(tinyMCE.execCommand('mceRemoveEditor', false, 'editorId')) {
// re-init..
}
我从this thread得到这个
【讨论】: