Input box initial focus

4 posts, 1 answers
  1. Jason Feng
    Jason Feng avatar
    3 posts
    Member since:
    Apr 2010

    Posted 07 Dec 2012 Link to this post

    I try to set focus to an input textbox in Kendo Window when the Window is opened, it set the focus then the focus is lost immediately. It was working before until recently. See code below:

       <div id="w">        
            <input id="t" />
        </div>

     var win = $('#w').kendoWindow({
                title: 'Test',
                visible: false
            }).data('kendoWindow');
    win.center().open();
    $('#t').select();
  2. Answer
    Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2622 posts

    Posted 11 Dec 2012 Link to this post

    Hi Jason,

    In order to achieve the desired behavior you could hook up to the activate event of the Kendo UI Window and then select the input. Like here:

    <div id="w">       
          <input id="t"/>
    </div>
     
    <script>
    var win = $('#w').kendoWindow({
        title: 'Test',
        visible: false,
        activate: function(){
          $('#t').select();
        }
    }).data('kendoWindow');
     
    win.center().open();
    </script>
     
    On a side note, there were some focus-related issues in the Kendo UI Window in v.2012.3.1114 which are now fixed. Therefore I recommend using the latest internal build which is available for downloading from your account.

    Regards,
    Iliana Nikolova
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Greg
    Greg avatar
    8 posts
    Member since:
    Apr 2018

    Posted 19 Jun 2018 in reply to Iliana Nikolova Link to this post

    I'm trying to set the focus on the text field for a kendoPrompt. The field was getting focus but then the kendo library was making some additional background changes. So I set the focus in a setTimeout javascript function with a 250ms delay and that re-set the focus on the text field after the kendo code completed running.  Hope that helps.

    setTimeout(function() {
        $(".k-prompt-container input.k-textbox").focus();
    }, 250);

  4. Ivan Danchev
    Admin
    Ivan Danchev avatar
    2063 posts

    Posted 21 Jun 2018 Link to this post

    Hello Greg,

    By default when the Prompt is opened its textbox is focused: see this dojo example. Could you elaborate more on the scenario that requires explicitly focusing the textbox with jQuery?

    Regards,
    Ivan Danchev
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top