Set focus in editor

5 posts, 0 answers
  1. Keith Knight
    Keith Knight avatar
    7 posts
    Member since:
    Feb 2010

    Posted 29 Mar 2012 Link to this post

    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?
  2. Dimo
    Admin
    Dimo avatar
    8396 posts

    Posted 29 Mar 2012 Link to this post

    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!
  3. Keith Knight
    Keith Knight avatar
    7 posts
    Member since:
    Feb 2010

    Posted 29 Mar 2012 Link to this post

    Thanks.  I should have seen that...
  4. Alex
    Alex avatar
    2 posts
    Member since:
    Nov 2016

    Posted 07 Jan Link to this post

    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>

  5. Alex
    Alex avatar
    2 posts
    Member since:
    Nov 2016

    Posted 10 Jan in reply to Alex Link to this post

    I finded a solution:

    ...

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

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

Back to Top