views:

115

answers:

1

Hello everyone!

I have some problem with Jquery Autocomplete plugin (http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/)

I got it working, but if I add new input field through AJAX (all fields are the same) - it doesn't autocomplete it.

I think the problem is because of "$().ready(function(){...." I think it doesn't accept dynamically loaded elements.

Please give me some advice how I can manage with this.

+2  A: 

You are creating new elements that weren't there to rig up autocomplete on when you ran the function initially. To resolve, just call autocomplete on your loaded elements. For example if you're using the success function (complete, etc will be the same way):

success: function(response) {
   //Do what you're doing now
   $(".shouldAutoComplete", response).autocomplete(...options...);
}

The ,response part tells the selector to only look at those new elements that just came in on the AJAX request.

Nick Craver
Thank you! It works!
kshchepelin