0

I'm having problem getting the textarea(ckeditor) value. This is the script line :

<script src="https://cdn.ckeditor.com/ckeditor5/11.1.1/classic/ckeditor.js"></script>

This is my textarea code :

 @Html.TextAreaFor(model => model.FullNews, new { @class = "form-control", @id = "Parag" })

This is my scripts section code :

 ClassicEditor
        .create(document.querySelector('#Parag'))
        .catch(error => {
            console.error(error);
        });



    function loadData() {
        debugger;
        var head = $("#Header").val();
        var para = CKEDITOR.instances.Parag.getData();
        document.getElementById("Para").innerHTML = para;
        document.getElementById("Head").innerHTML = head;
        readURL(document.getElementById("newsImage"));
        $("#previwe_before_publish").modal("show");
    }

When i debug it in browser, i get the error "Uncaught ReferenceError: CKEDITOR is not defined" in the line :

var para = CKEDITOR.instances.Parag.getData();

I searched over the internet but couldn't find the solution for it. Can anybody help me ?

Shiwa
  • 101
  • 1
  • 12
  • @StephenMuecke I haven't defined that. I have only used the cdn link that I have mentioned above. Nothing more than the code above. Can you suggest me what more should I do ? – Shiwa Nov 20 '18 at 05:07
  • @charlietfl I did. same error. – Shiwa Nov 20 '18 at 05:08

1 Answers1

0

CKEDITOR.instances simply is not defined in CKEditor 5. According to this section of the CKEditor 5 FAQ:

What happened to the global window.CKEDITOR? How to list all instances of the editor?

By default, CKEditor 5 has no global registry of editor instances. But if necessary, such feature can be easily implemented as explained in the Stack Overflow answer.

However, it is defined in CKEditor 4. Refer to the StackOverflow answer referenced in the CKEditor 5 documentation, or shift to CKEditor 4 for your code to function.

Community
  • 1
  • 1
Max K
  • 656
  • 1
  • 6
  • 22
  • Thanks ! It worked. Since I found out now that the question has already been asked before, should I delete this question ? I mean what's the general convention in stackoverflow ? – Shiwa Nov 20 '18 at 05:31
  • @Shiwa mark this answer has correct, upvote it if it is clear and logical / helped you easily, and then someone can mark it as a duplicate. – Max K Nov 20 '18 at 05:33
  • Okay. I marked it as correct. But I couldn't upvote it due to my low reputation. Are you sure I'm not supposed to delete this question ? – Shiwa Nov 20 '18 at 05:35
  • @Shiwa StackOverflow has a duplicate flagging system so that if a question like this is asked by someone else and they end up here instead, they can be routed to the duplicate. I have flagged the question and a moderator will eventually come through and accept the question as duplicate. – Max K Nov 20 '18 at 05:37
  • If you flagged as a duplicate you should NOT have added an answer! –  Nov 20 '18 at 05:38
  • @StephenMuecke I flagged this as a duplicate after I added an answer, per the request of the OP. So perhaps you mean that I should not flag this as duplicate if I added an answer? – Max K Nov 20 '18 at 05:41