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 1077637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:36:15+00:00 2026-05-16T21:36:15+00:00

I need an auto-complete in the app I’m working on and, since I’m already

  • 0

I need an auto-complete in the app I’m working on and, since I’m already using jQuery UI, I’m trying to make its Autocomplete widget meet my needs.

Step one is to make the search term only match at the beginning of suggested terms. I’ve already got that working, as you can see in the code below. Step two is to have the first suggestion actually autocomplete.

Which probably requires a bit of explanation. When I hear “autocomplete”, I envision typing “f” and having the contents of the text field change to “foo”, with the “oo” selected, so that it is replaced if I type another character and left in the field if I tab out of it. I’d normally call what the Autocomplete widget does suggesting, rather than autocompleting.

Looking at how Autocomplete works internally, I think the autocompleteopen event is the correct place to do this (it’s called every time the list of suggestions is updated), but I’m at a loss as to how to access the suggestion list from there.

Any thoughts?

$("#field").autocomplete({
    delay: 0,

    source: function filter_realms(request, response) {
        var term = request.term.toLowerCase();
        var length = term.length;

        response($.grep(candidates, function(candidate) {
            return candidate.substring(0, length).toLowerCase() === term;
        }));
    },

    open: function(event, ui) {
        // magic happens here?
    }
});
  • 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-05-16T21:36:16+00:00Added an answer on May 16, 2026 at 9:36 pm

    Got it. I’d forgotten that widgets can be accessed via .data().

    $("#field").autocomplete({
        delay: 0,
    
        source: function filter_realms(request, response) {
            var term = request.term.toLowerCase();
            var length = term.length;
    
            response($.grep(candidates, function(candidate) {
                return candidate.substring(0, length).toLowerCase() === term;
            }));
        },
    
        open: function(event, ui) {
            var current = this.value;
            var suggested = $(this).data("autocomplete").menu.element.find("li:first-child a").text();
    
            this.value = suggested;
            this.setSelectionRange(current.length, suggested.length);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project where I need a jQuery auto-complete for Cities. What
I am using jquery autocomplete and trying to define the values for the auto
I need help in jquery. Thanks in advance. I am using autocomplete function of
I have read several articles/questions/forums discussing the best auto-complete plugin for jQuery. After trying
I'm working on a jQueryMobile application with some form fields that need auto complete
I am building some auto-complete functionality using compass and I need to add an
I am trying to implement this jQuery auto complete function but the problem is
I need add Auto complete on apex Tabular Form. there is a column as
I have a problem with using facet. I need autocomplete and for this I
Hi I need help with setting up the rails3-jquery-autocomplete gem with a manually assigned

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.