Nikunj WA
Nikunj WA

Reputation: 45

KendoEditor Set focus at the end of text

I am using kendoEditor. I am inserting text in this editor dynamically. Whenever I insert text in editor , focus of cursor is not getting properly. I have used below code to focus on editor.

        var editor = txt.data("kendoEditor");
        var editorValue = editor.value();
        editor.value('');
        editor.value(editorValue + selectedName);
        editor.focus();

with this code, every time it focus at the start of the editor.
But, I need to focus at the end of inserted text.
So, how can I implement this ?
is there any solution about this?

Upvotes: 2

Views: 2410

Answers (1)

Gene R
Gene R

Reputation: 3744

add this code after editor.focus();

var range = editor.createRange();
range.selectNodeContents(editor.body);
range.collapse(false);
editor.selectRange(range);

Upvotes: 3

Related Questions