Using autocomplete, assinging autocomplete to the same element more than one time

Using autocomplete, assinging autocomplete to the same element more than one time

Hey all,

I am working on a page that has multiple divs with similar contents. I am using auto complete for  the text boxes, right now I am calling atuocomplete on them once the document it is ready. Something like :

  1. <input class = 'name' type = 'text' />
  2. <input class = 'price' type = 'text' />
  3. //then in the script
  4. $(".name").autocomplete({
  5. $(".price").autocomplete({
This works fine, the problem is now I am going to have to dynamically add more of these types of elements using Javascript, something like :

  1.             var item = "<div class = 'item'><p>";
                item += "<input class = 'name' name = 'name'  type = 'text' />";
                item += "<input class = 'price' name = 'occupation' type = 'text' / >";
                item += "</p></div>";


  2.             $("#cont").append(item);
Now because this is happening after the document ready event these new text are not auto completes. I was thinking what I could do is make a function that turns the textboxes into autocompletes and just call that function during document ready and again after a new item div is appended. This would mean that some of the textboxes could have auto complete called on them multiple times. Could anyone tell me if this would cause any sort of conflicts or memory problems? Could anyone suggest a better way to do this? Any advice or suggestions would be very much appreciated, thanks!

Jstall