javascript - CckEditor - 未捕获类型错误 : Cannot read property 'getSelection' of undefined

标签 javascript jquery ckeditor

我正在我的应用程序中实现CKEditor。当我尝试将 CKEditor 实例化到文本区域时,出现以下错误

Cannot read property 'getSelection' of undefined

在 ckeditor 的下面一行

getNative: function() {
 return void 0 !== this._.cache.nativeSel ? this._.cache.nativeSel : this._.cache.nativeSel = B ? this.document.$.selection : this.document.getWindow().$.getSelection() }

非常感谢任何帮助。

最佳答案

  1. 我有一个文章列表。
  2. 每次我点击任何文章时,都会打开一个“对话框/模式”。
  3. 在这样的对话框或模式中,有一个用于我文章内容的 ckeditor 元素。
  4. 当我点击第一个时,它就像一个魅力。
  5. 问题出在点击第二个、第三个、第四个等之后。

然后我开始遇到这个错误。

    TypeError: Cannot read property 'getSelection' of undefined
    at CKEDITOR.dom.selection.getNative (ckeditor.js:448)
    at new CKEDITOR.dom.selection (ckeditor.js:446)
    at a.CKEDITOR.editor.getSelection (ckeditor.js:443)
    at new CKEDITOR.plugins.undo.Image (ckeditor.js:1182)
    at CKEDITOR.plugins.undo.UndoManager.save (ckeditor.js:1177)
    at a.<anonymous> (ckeditor.js:1173)
    at a.n (ckeditor.js:10)
    at a.CKEDITOR.event.CKEDITOR.event.fire (ckeditor.js:12)
    at a.CKEDITOR.editor.CKEDITOR.editor.fire (ckeditor.js:13)
    at a.setData (ckeditor.js:275)

对我来说,解决方案很简单,告诉计算机在对话框/模式关闭时销毁 ckeditor 实例。简单的!.. 现在工作得很好 =)

           $mdDialog.show({
             parent:      parentEl,
             targetEvent: $event,
             templateUrl: '/md-templates/blog-article.html',
             controller:  DialogController,
             scope:         $scope,
             preserveScope: true,
            onRemoving: function (event, removePromise) {
                if (CKEDITOR.instances.body) CKEDITOR.instances.body.destroy();
            }
        });

关于javascript - CckEditor - 未捕获类型错误 : Cannot read property 'getSelection' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42005430/

相关文章:

javascript - 如何检查 qml 中的现有文件夹?

javascript - 使用 'order' 属性在兄弟之间定位 flex 元素

java - 在服务器端运行 javascript

javascript - 如何将 @media 打印样式应用于 ckeditor 实例?

javascript - 使用 barba.js 在新页面中将滚动位置设置为顶部

php - Jquery/PHP ajax 表单提交问题

javascript - 在不重新加载页面的情况下更新 URL 哈希

javascript - 简单的新闻提要 : Without Server-Side Languages

javascript - Bootstrap 模式窗口顶部的 CKEditor 对话框存在问题

javascript - 轻松升级 Ckeditor