Reputation:
I have a div that when clicked will open up the CKEDITOR. I want the contents of the div to be loaded into the editor. When i click off the editor i want the contents of the editor to be displayed in the div.
Here is my code:
<script>
var editor;
$(function () {
if (editor != null) {
editor.destroy(true);
}
else {
editor = null;
}
editor = CKEDITOR.replace('editor1');
$('.textObj').on('dblclick', function () {
$('#cke_editor1').show();
$("#cke_1_contents").html($('.textObj').html());
})
$('#cke_1_top').on('dblclick', function () {
$('.textObj').html($('#cke_1_contents').html());
$('#cke_editor1').hide();
})
</script>
<div class="textObj">Here is some Text</div>
<textarea name="editor1" id="editor1" contenteditable="true"></textarea>
When i double click the div it opens the editor as expected and the editor does contain the text from the div. However i am not able to edit the text and when i click on one of the buttons i get the error: Uncaught TypeError: Cannot read property 'getSelection' of undefined.
Can anyone help with this?
Upvotes: 0
Views: 1738