TinyMCE在jqueryUI模式对话框中打开

时间:2013-06-12 19:06:49

标签: javascript jquery-ui tinymce jquery-ui-dialog

在jqueryUI模式对话框中使用tinyMCE时,我无法使用超链接或“插入图像”功能。

基本上,经过大量搜索,我发现了这个:

http://www.tinymce.com/develop/bugtracker_view.php?id=5917

奇怪的是,对我而言,由于当jqueryUI的模态属性设置为false时问题不存在,因此它不会产生一个小问题,而且更多的是jqueryUI问题。

有了更丰富的形式,我看到发生的事情是,只要tinyMCE失去焦点,表格中的第一个元素就会聚焦,即使它不是聚焦/点击的那个。

有些JavaScript大师是否知道如何保持对话模态并使tinyMCE有效?

3 个答案:

答案 0 :(得分:5)

当重写_allowInteraction时不会:

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

我真的不能相信它。我是从 this thread on the TinyMCE forums得到的。 (他们将他们的bugtracker移到了github。tinymce/issues/703是相应的github问题。)

答案 1 :(得分:0)

似乎还没有针对此问题的适当解决方案。这是一种黑客攻击,但它真的对我有用。 每次打开对话框时,请删除文本区域并重新添加,如下所示,

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

答案 2 :(得分:-1)

这似乎可以解决它,或至少解决它(把它放在你的$(文件).ready())中:

$.widget('ui.dialog', $.ui.dialog, {
    _allowInteraction: function(event) {
        return ($('.mce-panel:visible').length > 0);
    }
});
相关问题