CKEditor无法读取未定义的属性“ getSelection”

时间:2018-12-22 22:20:10

标签: jquery ckeditor

我已经建立了自己的管理面板。菜单中包含指向html文件的链接,这些HTML文件会在页面自我加载后加载json。

[管理页面的HTML]

<body style="background-image: url(<?php echo $lgbackground ?>);">
    <div class="filter no_print"></div>
    <div class="header"></div>      
    <div class="content">
        <div id="content">
            <div id="jq_r">Administrator heeft javascript nodig om te kunnen werken, het lijkt erop dat javascript af staat. Gelieve dit in te schakelen om administrator te kunnen gebruiken.</div>
        </div>
    </div>
    <div class="navbar">
        <ul id="menu">
            <li>
                <a class="link " href="#home" data-href="module/home/index.php">
                    <i class="fas "></i>
                    <span>Home</span>
                </a>
            </li>
            ...
        </ul>

        <div class="footer"></div>

        <!-- notifications -->
        <ul id="notifications"></ul> 

        <div id="dialoghtml" title="Bewerk Broncode.">
            <div id="dialoghtml_body"><textarea id="ckhtmleditor" name="ckhtmleditor" class="ckeditor htmleditor">Laden...</textarea><button class="htmleditorpost">Opslaan</button></div>
        </div>
    </body>
</html>

在底部,我有一个CKEditor的对话框。打开对话框后,它将通过json从数据库加载内容。

[创建ckeditor的函数(多次触发)]

function load_ui() {
    $("textarea.ckeditor").each(function( index ) {
        if($(this).attr("data-ckeditor") != "true") {
            $(this).attr("data-ckeditor", "true").ckeditor();
        }
    });
}

加载Ajax之后 [如何更改编辑器的内容]

CKEDITOR.instances.ckhtmleditor.setData(data.respons);

问题是在加载另一个页面之后,我遇到了下一个错误:

Uncaught TypeError: Cannot read property 'getSelection' of undefined
at CKEDITOR.dom.selection.getNative (ckeditor.js:462)
at new CKEDITOR.dom.selection (ckeditor.js:460)
at a.CKEDITOR.editor.getSelection (ckeditor.js:457)
at $.<anonymous> (ckeditor.js:387)
at a.p (ckeditor.js:10)
at a.<anonymous> (ckeditor.js:12)
at a.CKEDITOR.editor.CKEDITOR.editor.fire (ckeditor.js:13)
at a.focus (ckeditor.js:288)
at HTMLDivElement.<anonymous> (sturing.js:454)
at HTMLDocument.dispatch (jquery-1.8.3.js:3058)

[我将链接加载到内容中的方式]

$.ajax({
    type: "GET",
    dataType: "html",
    url: href,
    success: function(data) {
        $("#content").html(data);
        reload_ui();
    },
    error: function(data) {
        .....
    }
});

有人可以帮我吗?尝试编辑内容时,我需要重新加载所有内容。经过一番挖掘后,似乎出现了iframe和dom的问题,但我不了解我的情况。

Greathings Christophe VD

0 个答案:

没有答案