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

set focus on autocomplete from select event in another autocomplete doesn't work

3 Answers 595 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
dmorgan
Top achievements
Rank 1
dmorgan asked on 19 Apr 2013, 09:19 PM
Hi!
I'm trying to create a simple form using two autocompletes (column1 and column2). I want the form to be fluent, so after the first autocomplete is selected I tried to set the focus on the next one. (using the select event in the first autocomplete)

I tried: 

$("#column2").focus(); and $("#column2").data("kendoAutoComplete")focus(); 
but it didnt't work.

I set up a sample in js fiddler

How can I achieve the desired behavior?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 22 Apr 2013, 11:37 AM
Hello Daniel,

 
You will need to use setTimeout in order to achieve your goal:

function autocomplete_select() {
            setTimeout(function() {
                $("#column2").focus();
            });
        }
Give it a try and let me know if the problem still persists.

Kind regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
dmorgan
Top achievements
Rank 1
answered on 22 Apr 2013, 09:04 PM
It worked!
thank you!. Can you explain me why do I need to use that setTimeout function?
0
Georgi Krustev
Telerik team
answered on 24 Apr 2013, 08:49 AM
Hello again Daniel,

The AutoComplete widget is designed to persist the focus of the input when popup element is clicked. The select is raised between of the open->click->close chain and that is why we will need to use setTimeout function to focus other input.

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
AutoComplete
Asked by
dmorgan
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
dmorgan
Top achievements
Rank 1
Share this question
or