Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tinymce 4 how to put cursor to end of the text

For some reason, I need to execute :

tinyMCE.activeEditor.setContent(text, {format : 'html'});

After that, how to put the cursor to the end of the text ?

like image 356
Hendry H. Avatar asked Nov 07 '13 06:11

Hendry H.


1 Answers

ed.selection.select(ed.getBody(), true); // ed is the editor instance
ed.selection.collapse(false);

This seems to be answered by Peter Wooster in thread jQuery Set Cursor Position in Text Area

EDIT For TINYMCE use:

tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
tinyMCE.activeEditor.selection.collapse(false);
like image 97
Hendry H. Avatar answered Sep 28 '22 01:09

Hendry H.