Reputation: 17
I'm trying to focus on the editor content. It puts the focus position at the beginning of the content, but it should be after the content. Can you suggest me how to move the focus position to the end of text?
<html>
<body>
<textarea id="mytextarea">
The focus will appear before this text. Should be after.
</textarea>
<script>
tinymce.init({
selector: '#mytextarea',
menubar: false,
});
setTimeout(function() {
tinymce.execCommand('mceFocus');
}, 2000)
</script>
</body>
</html>
Here is the working example https://jsfiddle.net/iosipov83/o10ut0g1/
Upvotes: 0
Views: 1343
Reputation: 13746
In your TinyMCE init you can add the following:
setup: function (editor) {
editor.on('init', function () {
editor.focus();
editor.selection.select(editor.getBody(), true);
editor.selection.collapse(false);
});
}
This should move the cursor to the very end of the content.
(Note: please don't double post your questions ... it would have been better to update your original post when someone asked for clarification)
Upvotes: 4