2
votes

CKEditor 4 not working, getting this error: ([CKEDITOR] Error code: editor-incorrect-element. {element: "body"} ckeditor.js:21 ).

My textarea has an id="body". I have added the script in the header. Everything is as it should be, but still not sure why it doesn't work. Any help is appreciated.

CKEDITOR.replace('body');

1

1 Answers

2
votes
<head>
    <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>

The editor operates on textarea elements, so create one in your body somewhere:

<textarea id="editor1" name="editor1"></textarea>

Then initialize the editor with the following code after the declaration of your textarea element:-

<script type="text/javascript">
    CKEDITOR.replace( 'editor1' );
</script>