Reputation: 8105
any ideas on how to scroll to bottom of a ckeditor editor using javascript / jQuery?
I cant find anything.
All my search shows is:
document.getElementById("ID").contentWindow.scrollTo(0,3);
Which gives me an error of contentWindow is undefined.
The class of the ckeditor text part appears to be "cke_editable".
Any help on scrolling to the bottom of the editor?
Upvotes: 2
Views: 3347
Reputation: 13432
Access the editor and get the editable area via that instead of getting the DOM element directly. Like so:
var editor = CKEDITOR.instances.editor1;
var jqDocument = $(editor.document.$);
var documentHeight = jqDocument.height();
jqDocument.scrollTop(documentHeight);
This works in the Demo: http://ckeditor.com/demo (you need var $ = jQuery;
if you try it in the console).
Note that your editor might not be named "editor1" - use the appropriate name for you.
Upvotes: 5