jQuery autocomplete not working on dynamically loaded elements -


i loading element through jquery ajax id 172. want apply autocomplete on element. following code not working.

$(document).ready(function(){           $( "#172" ).autocomplete({                 minlength: 2,                       source: function(request, response) {                     var results = $.ui.autocomplete.filter(jsoncities, request.term);                     response(results.slice(0, 10));                 },                       focus: function( event, ui )                  {                     $( "#172" ).val( ui.item.label );                             return false;                       },                       select: function( event, ui ) {                     $( "#172" ).val( ui.item.label );                             $( "#172-id" ).val( ui.item.value );                     return false;                       }                 }); }); 

i have observed doesnt work dynamically loaded element. missing ? correct way or other way there?

something work

$.ajax({ url:"..." type:"...", success:function(){     //add #172 element , use autocomplete on     $( "#172" ).autocomplete({})  }  }); 

since element not on dom when call autocomplete function nothing gets autocomplete behavior, use if after add element dom in ajax call.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -