#9546 closed Bug (invalid)
CK Editor - Place cursor at the end of text
Reported by: | Sridhar | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | 3.0.1 |
Keywords: | Cc: | spenuma@… |
Description
Hi,
I need to place the cursor at the end of text in the textarea when page loads.
Contact Email Address:sridhar_raju2000@yahoo.com,spenuma@templeton.com
Thanks, Sridhara Raju
Attachments (1)
Change History (6)
Changed 12 years ago by
comment:1 Changed 12 years ago by
I have used focus() method. But its placing begining of the text and not at the end of text.
comment:2 Changed 12 years ago by
I have used focus() method. But cursor placing begining of the text and not at the end of text. Is there any way to place the cursor at the end of text?
comment:3 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Please note that the CKEditor development website is not the right place for support requests.
Please refer to the following article for information on where to get support for all issues related to CKEditor: http://docs.cksource.com/CKEditor_3.x/Howto/Support
Also try using our forums for advice: http://cksource.com/forums/
If you are looking for professional assistance, the CKEditor development team is available via a dedicated support channel that is included in all our commercial licenses: http://ckeditor.com/license
- First of all please use the latest version of editor. Current is 3.6.5 and 4.0 will soon be released.
- You have to focus editor, get document object, put it in range, collapse range (with false parameter), select body (with selectNodeContents), collapse it (with false parameter) and finally select range. It is best to do it all in instanceReady event.
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dom.range.html
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#event:instanceReady
comment:4 Changed 12 years ago by
I have used below code. But for HTML <LI> Tags its not working consistently. Please send me the sample code.
$(document).ready(function() {
CKEDITOR.on('instanceReady', function(ev) {
ev.editor.focus();
var s = ev.editor.getSelection(); getting selection var selected_ranges = s.getRanges(); getting ranges var node = selected_ranges[0].startContainer; selecting the starting node var parents = node.getParents(true);
node = parents[parents.length - 2].getFirst();
while (true) {
var x = node.getNext(); if (x == null) {
break;
} node = x;
}
s.selectElement(node); selected_ranges = s.getRanges(); selected_ranges[0].collapse(false); false collapses the range to the end of the selected node, true before the node. s.selectRanges(selected_ranges); putting the current selection there
}
});
comment:5 Changed 12 years ago by
The above code puts cursor at the end of selected node not at the end of document. I have described how it can be done with pseudo code - please try to implement it.
One more thing this is not support site but place for reporting bugs!!!
Issue