0

我有一个带有tinymce的jquery UI对话框,第一次打开对话框时tinymce工作正常,但是一旦我关闭对话框并重新打开它,我就会看到tinymce编辑器,但我不能在里面输入任何东西,就好像它一样被禁用。

4

3 回答 3

1

问题在这里看起来很清楚。关闭 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();


});
于 2012-04-25T15:12:28.107 回答
0

我通过延迟功能解决了这个问题:

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);
于 2012-04-27T17:08:31.460 回答
0

这个就像一个魅力:

if(tinyMCE.execCommand('mceRemoveEditor', false, 'editorId')) {
  // re-init..
}

我从这个线程得到这个

于 2016-05-17T03:07:26.370 回答