Jquery autocomplete on dynamically loaded fields problem
I have some problem with 开发者_如何学PythonJquery 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.
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.
精彩评论