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

4 posts, 1 answers
  1. Answer
    dmorgan
    dmorgan avatar
    5 posts
    Member since:
    Oct 2012

    Posted 19 Apr 2013 Link to this post

    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!
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 22 Apr 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. dmorgan
    dmorgan avatar
    5 posts
    Member since:
    Oct 2012

    Posted 22 Apr 2013 Link to this post

    It worked!
    thank you!. Can you explain me why do I need to use that setTimeout function?
  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 24 Apr 2013 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready