Search code examples
jqueryjquery-uitinymcejquery-dialog

Why does Tinymce fails to initiate once jquery dialog box is closed and reopened?


I have a jquery UI dialog box with tinymce inside of it, the first time I open the dialog box tinymce works fine but once I close the dialog box and reopen it I see the tinymce editor but I can't type anything inside as if it is disabled.


Solution

  • I have resolved the problem by delaying the function:

    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);