CKEditor内部的jQuery模式问题与按钮

CKEditor inside jQuery modal issue with buttons

本文关键字:问题 按钮 模式 jQuery 内部 CKEditor      更新时间:2023-09-26

我正在使用 CKEditor 4.4.7 问题是当我打开我的模态对话框时,女巫包含 CKEditor,我正在尝试使用背景颜色或文本颜色按钮,如果我没有从列表中选择任何颜色并关闭它,之后我在控制台中收到错误:

类型错误: a.contentWindow 为空 类型错误: 这。.panel..iframe.getFrameDocument(...).getById(...) 为空

并且这些按钮不再工作,每当我尝试按下它们时,它们都不会再次打开任何菜单,直到我不刷新页面。

这是我的模式对话框的代码。

<form action='' method='post'>
    <textarea id='editor1' name='editor1'></textarea>
    <script type="text/javascript">
        CKEDITOR.replace('editor1');
    </script>
    <input type="submit" name="submitComment" value="Submit" />
</form>

问题是什么以及如何解决?谢谢。

这听起来类似于这里描述的问题:https://forum.jquery.com/topic/can-t-edit-fields-of-ckeditor-in-jquery-ui-modal-dialog#14737000005423723在这里:http://bugs.jqueryui.com/ticket/9087#comment:30(此处描述的解决方案似乎不再有效)。

我的解决方案如下:

orig_allowInteraction = $.ui.dialog.prototype._allowInteraction;
$.ui.dialog.prototype._allowInteraction = function(event){
    // address interaction issues with general iframes with the dialog
    if (event.target.ownerDocument != this.document[0]){
        return true;
    }
    // address interaction issues with dialog window
    if ($(event.target).closest(".cke_dialog").length){
        return true;
    }
    // address interaction issues with iframe based drop downs in IE
    if ($(event.target).closest(".cke").length){
        return true;
    }
    return orig_allowInteraction.apply(this, arguments);
};

这个解决方案并不完美,因为我在 Firefox 中遇到了"太多递归"错误,但它在大多数情况下都有效。如果您有其他问题,我深表歉意。