TinyMCE opened in jqueryUI modal dialog

白昼怎懂夜的黑 提交于 2019-12-05 04:25:25
Bradley Mountford

This fixed it for me when overriding _allowInteraction would not:

$(document).on('focusin', function(e) {
    if ($(event.target).closest(".mce-window").length) {
        e.stopImmediatePropagation();
    }
});

I can't really take credit for it. I got it from this thread on the TinyMCE forums. (They have moved their bugtracker to github. tinymce/issues/703 is the corresponding github issue.)

It seems there are no propper solution for this issue yet. This is kind of a hack but it really worked for me. Every time you open the Dialog remove the text area and re add it like following,

var myDialog = $('#myDialog');
var myTextarea = myDialog.find('textarea');
var clonedTextArea = myTextarea.clone(); // create a copy before deleting from the DOM
var myTextAreaParent = myTextarea.parent(); // get the parent to add the created copy later

myTextarea.remove(); // remove the textarea

myDialog.find('.mce-container').remove(); // remove existing mce control if exists

myTextAreaParent.append(clonedTextArea); // re-add the copy

myDialog.dialog({
   open: function(e1,e2){
        setTimeout(function () {
             // Add your tinymce creation code here
       },50);
   }
});

myDialog.dialog('open');

This seems to fix it for me, or at least work around it (put it somewhere in your $(document).ready()):

$.widget('ui.dialog', $.ui.dialog, {
    _allowInteraction: function(event) {
        return ($('.mce-panel:visible').length > 0);
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!