ckeditor 5, v1.11.1
I have initialised an editor as follows:
<textarea name="content" id="editor"></textarea>
<script>
ClassicEditor
.create( document.querySelector( '#editor' ) )
.then( editor => {
console.log( editor );
} )
.catch( error => {
console.error( error );
} );
</script>
I am making an ajax call (via jquery) and attempting to populate the editor with the response:
<script>
$(function() {
$.ajax({
url: '/get-editor-data',
method: 'get'
}).done(function (response) {
$('#editor').html(response.comment);
});
});
</script>
The ajax request is running successfully and returning valid JSON:
{"comment":"foo"}
So the content "foo" should appear in the editor.
But I'm getting an editor without any content in it.
If I disable ckeditor - by commenting out the first block of js (ClassicEditor...
) - so it's just a vanilla textarea the content is populated correctly.
So how do I get the content in the editor in this way?