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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:21:46+00:00 2026-06-07T12:21:46+00:00

I am modifying some jquery autocomplete code. The current code works fine, and the

  • 0

I am modifying some jquery autocomplete code. The current code works fine, and the response list is generated programmatically, but I want to add a hard coded “All Companies” at the top of my response list, which will act just like the other entries in the response list. Here is the code I am working with:

    $(function() {
    $( "#report_generator_search" ).autocomplete({
        source: function( request, response ) {
            $.ajax({
                url: "lib/test.php",
                dataType: "json",
                type: "POST",
                data: {
                    action: "search_test",
                    featureClass: "P",
                    style: "full",
                    maxRows: 24,
                    searchTerm: request.term
                },
                success: function( f ) {
                    response( $.map( f, function( item ) {
                        return {
                            label: item.company_name + ' ('+item.company_id+') ' + item.generator_address,
                            value: item.company_name,
                            company_id: item.company_id
                        }
                    }));        
                }
            });
        },
        minLength: 1,
    });

I have tried simply adding another response, but no go:

    response( $.map( f, function( item ) {
                        return {
                        label: "All Companies",
                        value: "All Companies",
                        company_id: ""
                    }
                    }));

And I have tried prepending, which puts “All Companies” at the top but the button doesn’t function at all like the other list elements:

    $('.ui-autocomplete').prepend('<li class="ui-menu-item" role="menuitem"><a class="ui-corner-all" tabindex="-1">All Companies</a></li>');

Any help would be appreciated. Thank you.

  • 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-07T12:21:47+00:00Added an answer on June 7, 2026 at 12:21 pm

    You can only call response() once. You’ll need to create a single list of results:

    success: function( f ) {
        // Begin with your hard-coded choices
        var staticChoices = [
            {
                label: "All Companies",
                value: "All Companies",
                company_id: ""
            }
        ];
    
        // Parse downloaded choices
        var dynamicChoices = $.map( f, function( item ) {
            return {
                label: item.company_name + ' ('+item.company_id+') ' + item.generator_address,
                value: item.company_name,
                company_id: item.company_id
            }
        });
    
        // Combine the two :)
        response(staticChoices.concat(dynamicChoices));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am modifying some code that has a lot of jQuery but I am
I'm modifying some code that I've been left with and want to add some
I'm modifying some code that calls enumerate on a list declared via a list
I'm monkey-patching some of the jQuery's Draggable code*. The goal is to avoid modifying
I am modifying some code for a Blackfin processor using VisualDSP++ v. 5.0. I
I'm working on modifying some existing code for a payment gateway and I'm not
I've been modifying some code to work between Mac OS X and iPhone OS.
I'm new to C# and directly diving into modifying some code for a project
I am struggling with modifying some code in Customer registration management module. Instant checkout
I'm modifying some .vcrpoj files in .NET but when I save them the formatting

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.