CkEditor - Uncaught TypeError: Cannot read property 'getSelection' of undefined
12,346
- I have a list of articles.
- every time I clicked on any article a "dialog / modal" should be open.
- in such dialog or modal there was a ckeditor element for the content of my article.
- when I clicked on the first it worked like a charm.
- the problem was after clicking on the 2nd, 3rd, 4th etc.
Then I started to have this error.
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)
The solution for me was easy, tell the computer to destroy the ckeditor instance when the dialog / modal is closed. easy!.. Now is working like a charm =)
$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();
}
});
Author by
Admin
Updated on June 05, 2022Comments
-
Admin almost 2 years
I am implementing the
CKEditor
in my app. When I am trying to instantiateCKEditor
to the textarea I am getting following errorCannot read property 'getSelection' of undefined
at below line of ckeditor
getNative: function() { return void 0 !== this._.cache.nativeSel ? this._.cache.nativeSel : this._.cache.nativeSel = B ? this.document.$.selection : this.document.getWindow().$.getSelection() }
Any help is much appreciated.
-
Brian Sanchez over 6 yearsI spent 20 mins writing my above instructions and a genius put it minus??.. you should see my script working. how can I report to stackoverflow? this?..
-
Bob Kaufman about 3 yearsI used your code successfully, except for whatever reason, it worked much better inside of
$(document).ready()