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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:47:53+00:00 2026-05-11T21:47:53+00:00

i have a problem.. I use the autocomplete plugin, that i edite for make

  • 0

i have a problem..

I use the autocomplete plugin, that i edite for make the input text to disappear when the user make the choice.

So, my goal is, when the user select a row from the autocomplete list:

  1. An Ajax request would retrieve additional info about the selected row (no problem here)
  2. A form auto-fillup with those additional info (ok here)
  3. The input-text with the autocomplete disappear, and at it place i put 2 div, one with a X inside (to ‘deselect’ the previus selection), and another with some short info about the selection itself (no problems here)
  4. If the user click the X div, all must be return as the begin, with the input-text with autocomplete.

What happen to me, is that at the point 4, all works fine, but when the input-text with autocomplete is recreated by

$("div#contact-list-container").html('<input type="text" name="contact-list" id="contact-list" value="" />');

the autocomplete wont work anymore!

So, how can i join the autocomplete function to the field when it is recreated? In order to let the user select and deselect it many times.

p.s: I know that i could simply hide the div with the input-text and show the one with the X, but i’ll prefer to keep the html markup minimal and dont mess around with hidden divs.
If is possible, i’ll like to change the innerHTML on every select and reassociate the autocomplete function.

Thats how my cose is now:

$(document).ready(function(){
    $('input#contact-list').autocomplete('test-db.php', {
        multiple: false,
        dataType: "json",
        width: 400,
        scrollHeight: 300,
        max: 5,
        parse: function(data) {
            return $.map(data, function(row) {
                return {
                    data: row,
                    value: row.azienda,
                    //result that will be used in the text field, while selected
                    result: row.code + ' - ' + row.company + ' | ' + row.name + ', ' + row.surname
                }
            });
        },
        formatItem: function(item) {
            return item.code + ' - ' + item.company + '<br />' + item.name + ', ' + item.surname + '<br />' + item.email;
        }
    }).result(function(e, item) {
        //this will be triggered when the selection has made
        $.ajax({
            type: "POST",
            cache: false,
            data: "idCompany=" + item.id_company + "&idUser=" + item.id_user,
            url: "test-db-02.php",
            success: function(message){
                $("input[rel='ship']").attr("readonly", true).css("background-color", "#DFDFDF");
                $("input[rel='company']").attr("readonly", true).css("background-color", "#DFDFDF");
                var rd = json_parse(message);

                $("input#ship-nome-referente").val(rd.company.nome);
                $("input#ship-cognome-referente").val(rd.company.cognome);
                //[... and so on, i change the val of many fields..]
                //REPLACE THE INPUT-TEXT WITH THE DIVS
                $("div#contact-list-container").html('<div id="deselect-contact">X</div><div id="selected-contact">' + rd.company.code + ' - ' + rd.company.company + ' | ' + rd.company.name + ', ' + rd.company.surname + '</div>');

                $("div#deselect-contact").click(function(){
                //REPLACE THE DIVS WITH THE INPUT-TEXT.. HOW TO REASSOCIATE THE AUTOCOMPLETE?
                    $("div#contact-list-container").html('<input type="text" name="contact-list" id="contact-list" value="" />');
                    $("input[rel='ship']").attr("readonly", false).css("background-color", "#FFFFFF").val('');
                    $("input[rel='company']").attr("readonly", false).css("background-color", "#FFFFFF").val('');
                });
            }
        });
    });
});
  • 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-11T21:47:54+00:00Added an answer on May 11, 2026 at 9:47 pm

    Since jQuery 1.3 the live() event has had the required functionality, which allows you to persistently bind events to handles, even if the handles get destroyed and recreated.

    Edit: live was deprecated in jQuery 1.7 and removed in 1.9, so now you should use on() instead to achieve the same effect.

    See http://api.jquery.com/on/ for details.

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

Sidebar

Ask A Question

Stats

  • Questions 205k
  • Answers 205k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This diverges a bit from what you started with, but… May 12, 2026 at 9:02 pm
  • Editorial Team
    Editorial Team added an answer This code should work: private static bool UrlExists(string url) {… May 12, 2026 at 9:02 pm
  • Editorial Team
    Editorial Team added an answer Move your function into a VB6 function that takes the… May 12, 2026 at 9:02 pm

Related Questions

I'm using the jQuery Autocomplete plugin , but I'm having some problems with the
So far I'm not finding the same problem in other questions on this site.
I have a set of pages that have tons of JavaScript on it: Table
A lot of lead up: I have a simple ASP .NET 3.5 data entry

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.