This is a migrated thread and some comments may be shown as answers.

Set focus in editor

4 Answers 1090 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Keith Knight
Top achievements
Rank 1
Keith Knight asked on 29 Mar 2012, 06:47 AM
I display the Kendo editor in a Kendo window.  After displaying it, I would like to set focus on the editor.  I have being trying variations of:
kendoEditor.element.focus();
kendoEditor.element.select('body').focus();

No luck so far.  Any suggestions?

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 29 Mar 2012, 08:32 AM
Hello Keith,

The focus() method of the Editor is of the widget object:

$("#EditorID").data("kendoEditor").focus();

If kendoEditor in your case is the textarea jQuery object, then try

kendoEditor.data("kendoEditor").focus();

Greetings,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Keith Knight
Top achievements
Rank 1
answered on 29 Mar 2012, 03:10 PM
Thanks.  I should have seen that...
0
Alex
Top achievements
Rank 1
answered on 07 Jan 2017, 10:23 PM

Help me please!

I can't set focus into editor. You can see a text below.

  <div id="example">
    <div class="demo-section k-content">
        <div>
            <h4>Enter some content</h4>
            <textarea data-role="editor" 
                      data-tools="['bold',
                                   'italic',
                                   'underline',
                                   'strikethrough',
                                   'justifyLeft',
                                   'justifyCenter',
                                   'justifyRight',
                                   'justifyFull']"
                      data-bind="visible: isVisible,
                                 value: html,
                                 events: { change: onChange }"
                      style="height: 200px;"></textarea>
        </div>
        <div style="padding-top: 1em;">
            <h4>Console</h4>
            <div class="console"></div>
        </div>
    </div>

<script>
    var viewModel = kendo.observable({
        html: null,
        isVisible: true,
        onChange: function() {
            kendoConsole.log("event :: change (" + kendo.htmlEncode(this.get("html")) + ")");
        }
    });
    kendo.bind($("#example"), viewModel);
</script>
</div>

0
Alex
Top achievements
Rank 1
answered on 10 Jan 2017, 09:25 AM

I finded a solution:

...

kendo.bind($("#example"), viewModel);

$('[data-role="editor"]').data('kendoEditor').focus();

Tags
Editor
Asked by
Keith Knight
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Keith Knight
Top achievements
Rank 1
Alex
Top achievements
Rank 1
Share this question
or