jQuery 对话框中的 CKEditor 实例

发布于 2024-08-27 17:11:05 字数 1687 浏览 7 评论 0原文

我正在使用 jQuery 打开一个对话框窗口,其中的文本区域转换为 CKEditor 的实例。我正在使用 CKEditor 团队提供的 jQuery 适配器,但是当对话框窗口打开时,我无法与编辑器交互(它已创建,但在内容空间中写入“null”,我无法单击任何内容或修改内容)。

此错误报告似乎说通过使用补丁可以解决问题,但事实并非如此似乎对我有用...

这是我的代码(也许我在编程上做错了什么):

HTML:

<div id="ad_div" title="Analyse documentaire">
<textarea id="ad_content" name="ad_content"></textarea>
</div>

我的包含(一切都正确包含,但可能是包含顺序问题?):

<script type="text/javascript" src="includes/ckeditor/ckeditor.js"></script>
<link rel="stylesheet" type="text/css" href="includes/jquery/css/custom-theme/jquery-ui-1.7.2.custom.css" />
<script type="text/javascript" src="includes/jquery/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="includes/jquery/js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="includes/jquery/plugins/dialog-patch.js"></script>
<script type="text/javascript" src="includes/ckeditor/adapters/jquery.js"></script>

Javascript:

$('#ad_content').ckeditor();

/* snip */

$('#ad_div').dialog(
{
    modal: true,
    resizable: false,
    draggable: false,
    position: ['center','center'],
    width: 600,
    height: 500,
    hide: 'slide',
    show: 'slide',
    closeOnEscape: true,
    autoOpen: false
});

$('.analyse_cell').click(function(){
    $('#ad_div').dialog('open');
});

编辑:经过一些进一步的测试,我注意到按下工具栏按钮给了我这个错误:

错误:this.document.getWindow().$ 是 未定义的源文件: 包含/ckeditor/ckeditor.js 行:82

I am using jQuery to open a dialog window with a textarea transformed into an instance of CKEditor. I'm using the jQuery adapter provided by the CKEditor team but when the dialog window opens up I cannot interact with the editor (it's created but "null" is written in the content space and I can't click on anything or modify the content).

This bug report seems to say that by using a patch provided the issue is fixed but it doesn't seem to be working for me...

Here's my code (maybe I did something wrong programmatically):

HTML:

<div id="ad_div" title="Analyse documentaire">
<textarea id="ad_content" name="ad_content"></textarea>
</div>

My includes (Everything is included correctly but maybe it's an including order issue?):

<script type="text/javascript" src="includes/ckeditor/ckeditor.js"></script>
<link rel="stylesheet" type="text/css" href="includes/jquery/css/custom-theme/jquery-ui-1.7.2.custom.css" />
<script type="text/javascript" src="includes/jquery/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="includes/jquery/js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="includes/jquery/plugins/dialog-patch.js"></script>
<script type="text/javascript" src="includes/ckeditor/adapters/jquery.js"></script>

Javascript:

$('#ad_content').ckeditor();

/* snip */

$('#ad_div').dialog(
{
    modal: true,
    resizable: false,
    draggable: false,
    position: ['center','center'],
    width: 600,
    height: 500,
    hide: 'slide',
    show: 'slide',
    closeOnEscape: true,
    autoOpen: false
});

$('.analyse_cell').click(function(){
    $('#ad_div').dialog('open');
});

Edit: After some further testing I noticed that pressing on the toolbar buttons gave me this error:

Error: this.document.getWindow().$ is
undefined Source File:
includes/ckeditor/ckeditor.js Line: 82

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

仅此而已 2024-09-03 17:11:05

我使用带有“show:”选项的回调函数来延迟实例化 CKEditor,直到“show”动画完成之后。我发现只要 50 毫秒就可以达到目的。

modal: true,
show: {
    effect: "drop",
    complete: function() {
        setTimeout(function(){
            $( "#selector" ).ckeditor();
        },50);
    }
},
hide: "drop",

希望这有帮助。

I used a callback function with the "show:" option to delay instantiating CKEditor until after the "show" animation was complete. I found that as little as 50 milliseconds will do the trick.

modal: true,
show: {
    effect: "drop",
    complete: function() {
        setTimeout(function(){
            $( "#selector" ).ckeditor();
        },50);
    }
},
hide: "drop",

Hope this helps.

冷了相思 2024-09-03 17:11:05
$('.analyse_cell').click(function(){
    $('#ad_div').dialog({
        modal: true,
        resizable: false,
        draggable: false,
        position: ['center','center'],
        width: 600,
        height: 500,
        hide: 'slide',
        show: 'slide',
        closeOnEscape: true,
        autoOpen: false,
        open: function(event,ui) {
            $('#ad_content').ckeditor();
        },
        close: function(event,ui) {
            CKEDITOR.remove($("#ad_content").ckeditorGet());
        }
    });
});
$('.analyse_cell').click(function(){
    $('#ad_div').dialog({
        modal: true,
        resizable: false,
        draggable: false,
        position: ['center','center'],
        width: 600,
        height: 500,
        hide: 'slide',
        show: 'slide',
        closeOnEscape: true,
        autoOpen: false,
        open: function(event,ui) {
            $('#ad_content').ckeditor();
        },
        close: function(event,ui) {
            CKEDITOR.remove($("#ad_content").ckeditorGet());
        }
    });
});
梦醒灬来后我 2024-09-03 17:11:05

使用最新版本的 CKEditor。为我解决了。版本3.4.2

Use the latest version of CKEditor. Solved it for me. Version 3.4.2

帥小哥 2024-09-03 17:11:05

只需将此代码片段添加到您的文档中即可解决问题!

$(document).on('focusin', function(e) {
     e.stopImmediatePropagation();
});

Simply add this snippet to your doc and the problem is solved!

$(document).on('focusin', function(e) {
     e.stopImmediatePropagation();
});
止于盛夏 2024-09-03 17:11:05

尝试将其放在适配器下方。修复方法是覆盖适配器。

Try putting the below the adapter. The fix is overriding the adapter.

寄风 2024-09-03 17:11:05

好吧,由于某种原因,我无法让它工作,但设法通过手动实现相同的功能来获得相同的效果。

Well for some reason I couldn't get it to work but managed to get the same effect by implementing the same functionality by hand.

半夏半凉 2024-09-03 17:11:05

我遇到了同样的问题,出于某种原因,我发现在打开对话框之前将一些文本放入文本区域可以解决问题。不是真正的解决方案,但对我有用。

$('#ad_content').ckeditor();

/* snip */

$('#ad_div').dialog(
{
    modal: true,
    /* Your options here. */
});

$('.analyse_cell').click(function(){
    // Add some content into textarea.
    $('#ad_content').val("Enter content here.");
    $('#ad_div').dialog('open');
});

I encountered the same problem and for some reason I found that putting some text into the textarea before opening the dialog could do the trick. Not a real solution, but works for me.

$('#ad_content').ckeditor();

/* snip */

$('#ad_div').dialog(
{
    modal: true,
    /* Your options here. */
});

$('.analyse_cell').click(function(){
    // Add some content into textarea.
    $('#ad_content').val("Enter content here.");
    $('#ad_div').dialog('open');
});
番薯 2024-09-03 17:11:05

我通过简单地在 jQuery UI 对话框构造函数中添加 zIndex=-1 来解决这个问题,如下所示

$('#modalWindow').dialog({ autoOpen: false, modal: true, zIndex : -1});

I solved this by simply adding zIndex=-1 in the jQuery UI Dialog constructor like so

$('#modalWindow').dialog({ autoOpen: false, modal: true, zIndex : -1});
ˉ厌 2024-09-03 17:11:05

我正在使用 jQuery 打开一个对话框窗口,其中的文本区域转换为 CKEditor 的实例。我正在使用 CKEditor 团队提供的 jQuery 适配器,但是当对话框窗口打开时,我无法与编辑器交互(它已创建,但在内容空间中写入了 null我无法点击任何内容或修改内容)。

错误:this.document.getWindow().$ 未定义 源文件:includes/ckeditor/ckeditor.js
线路:129

我使用的是版本 3.6.2

I am using jQuery to open a dialog window with a textarea transformed into an instance of CKEditor. I'm using the jQuery adapter provided by the CKEditor team but when the dialog window opens up I cannot interact with the editor (it's created but null is written in the content space and I can't click on anything or modify the content).

Error: this.document.getWindow().$ is undefined Source File: includes/ckeditor/ckeditor.js
Line: 129

I am using Version 3.6.2

Spring初心 2024-09-03 17:11:05

刚刚通过禁用弹出对话框(显示选项)上的 jQuery UI 效果解决了完全相同的问题。

我花了很长时间才弄清楚这一点。现在编辑器的表现符合预期。

Just solved the exact same problem by disabling the jQuery UI effect on the popup dialog (show option).

Took me like forever to figure this out. Now the editor is behaving as expected.

夏末染殇 2024-09-03 17:11:05

神秘主义,但它对我有帮助。
在创建对话框之前,我强制设置空数据

CKEDITOR.instances['email_text_of_message'].setData('')

,并且对话框中的 ckeditor ("ckeditor", "~> 3.4") 工作正常。

$("#create_email").click(function(event){

CKEDITOR.instances['email_text_of_message'].setData('')

$("#email_body").dialog({    modal: true,
                             minHeight: 720,
                             minWidth: 900,
                             buttons: [
                            {
                             id: "button_create_email",
                             text: $('#inv_notice16').text(),
                             click: function() {
                                    $("#email_body").dialog('close')
                           }
                            }]}); 
    return false;       
})

Mysticism, but it helped for me.
Before create dialog i forcibly set empty data

CKEDITOR.instances['email_text_of_message'].setData('')

and ckeditor ("ckeditor", "~> 3.4") in dialog works fine.

$("#create_email").click(function(event){

CKEDITOR.instances['email_text_of_message'].setData('')

$("#email_body").dialog({    modal: true,
                             minHeight: 720,
                             minWidth: 900,
                             buttons: [
                            {
                             id: "button_create_email",
                             text: $('#inv_notice16').text(),
                             click: function() {
                                    $("#email_body").dialog('close')
                           }
                            }]}); 
    return false;       
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文