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

  • SEARCH
  • Home
  • 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

Related Questions

If I have a choice to use recursion or memoization to solve a problem
I use JQuery plugin autocomplete as a kind of dataset chooser. If the user
I have use rails3-jquery-autocomplete plugin and I am just wondering how can I use
I have found a problem with use JQuery timeout, i have a page with
I have a problem with a bash script. I have to use the operator
I still have a problem with the splash screen. I don't want to use
I have hit upon this problem about whether to use bignums in my language
I have this .bat script which I use to maven package my application. Problem
I've just started to use linq to sql and have run into a problem
I'm having a strange problem. I have to use GetPostBackEventRefence to force a Postback,

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.