1

I am displaying a CK editor on uibmodal window using angular js.

 <div>
 <textarea ckeditor="editorOptions" id="ckID" ng-model="content"></textarea>
 </div>

I want to insert a piece of text in the CK Editor on click of a button named 'insertDynamicContent1' and am using the below;

    $scope.insertDynamicContent1 = function(str) {

        CKEDITOR.instances[ckID].insertText(str);

    };

I am getting the following error-

angular.js:11607 TypeError: Cannot read property 'insertText' of 
undefined
at l.$scope.insertDynamicContent1 (templates-controller.js:191)
at angular.js:12345
at f (angular.js:21438)
at l.$eval (angular.js:14401)
at l.$apply (angular.js:14500)
at HTMLButtonElement.<anonymous> (angular.js:21443)
at HTMLButtonElement.c (angular.js:3014)

I went through stack posts How to use CKEditor in a Bootstrap Modal? that specifies to modify the z-index value for CK editor or the model window, so i did the below;

//added it to ck-ediotr's config.js
config.baseFloatZIndex = 20000; 

//added it to the css to modify the model class
.custom-dialog .modal-dialog {
z-index: 10000 !important;
width: 90%;
top: 30%;
}

I am still facing the same error and i have no clue on what is going on. Any help would be appreciated.

Thank You!

  • Welcome to SO. The error states that `CKEDITOR.instances[ckID]` is `undefined`. Since `ckID` doesn't seem to be a variable, could you try replacing it with `CKEDITOR.instances['ckID']`? If that does not work, could you please tell us whether you are using version 4 or 5? – Florian Lim Jan 28 '19 at 12:00
  • Thank you so much! It worked, my bad miss :/ – Sruthi Emmidi Jan 28 '19 at 12:30
  • Glad to hear it. I'll put my comment as an answer then. – Florian Lim Jan 28 '19 at 12:33
  • I have up-voted your answer but i don't think it will be visible as my reputation<15 points.. – Sruthi Emmidi Jan 28 '19 at 12:44
  • You don't have to upvote it (it probably won't help others anyway, because it was a really specific problem). Simply accept it, so that others can see that the problem was solved. – Florian Lim Jan 28 '19 at 12:56

1 Answers1

0

The error states that CKEDITOR.instances[ckID] is undefined. Since ckID is not a variable, the reference has to be replaced with

CKEDITOR.instances['ckID']

Florian Lim
  • 5,332
  • 2
  • 27
  • 28