Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8391493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:16:39+00:00 2026-06-09T19:16:39+00:00

I have a textbox bound to jQuery UI’s autocomplete. When the user selects an

  • 0

I have a textbox bound to jQuery UI’s autocomplete. When the user selects an option from the autocomplete dropdown, JSON data is used to populate a form with user details from a remote source.

I have a reset button with the following function bound to it:

$('#btn_reset').on('click', function() {
    $('#txt_name').autocomplete('search');
    $('.ui-menu-item').children().eq(0).click();
    return false;
});

This works with a small amount of local data as search is completed before click() is called, however with a large amount of external data, the search does not complete in time, thus giving me an 'item' is null or not an object error.

How can I get jQuery to wait until search is completed before calling click()?

Here is a working fiddle using a local data source: http://jsfiddle.net/3KTtT/3/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:16:41+00:00Added an answer on June 9, 2026 at 7:16 pm

    The solution was to bind a function to the open event of autocomplete to check for a boolean variable to determine whether or not the form was being reset.

    var reset = false;
    $(function() {    
        $('#txt_name').autocomplete({
            source: [{"label":"john smith","address":"19 Tree Lane"}],
            delay: 0,
            autoFocus: true,
            open: function() {
                if(reset){
                    $('.ui-menu-item').children().eq(0).click();
                    reset = false;
                }
            },
            select: function(event, ui) {
                $('#txt_address').val(ui.item.address);
            }
    
        });
    
        $('#btn_reset').on('click', function() {
            reset = true;
            $('#txt_name').autocomplete('search');
            return false;
        });
    
    });
    

    See here for fiddle: http://jsfiddle.net/RVnkz/2/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox bound to a property. The property continously gets updated from
I have a html textbox on which I've bound a function via jQuery to
I have a Windows Form with data bound textBox which displays a phone number
I am trying to create an autocomplete textbox using jquery which will be bound
I have a TwoWay data-bound textbox inside my page. I want to do something
I have a textbox bound to a currency data field. So it adds '$'
I have a TextBox bound to a property of an object which implements IDataErrorInfo
I have a TextBox in a WPF window bound to a dependency property of
I have a string property bound to a textbox. On the same screen there
Desktop window application. I have textbox in which user give values in numbers. what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.