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

Input box initial focus

3 Answers 674 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jason Feng
Top achievements
Rank 1
Jason Feng asked on 07 Dec 2012, 02:23 PM
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();

3 Answers, 1 is accepted

Sort by
0
Accepted
Iliana Nikolova
Telerik team
answered on 11 Dec 2012, 01:57 PM
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!
0
Greg
Top achievements
Rank 1
answered on 19 Jun 2018, 07:03 PM

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);

0
Ivan Danchev
Telerik team
answered on 21 Jun 2018, 08:20 AM
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.
Tags
Window
Asked by
Jason Feng
Top achievements
Rank 1
Answers by
Iliana Nikolova
Telerik team
Greg
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or