javascript - how to clear and add source data dynamically in jquery autocomplete -


this jquery code.year form input tag id.years array variable it's contain years values.i put array in autocomplete source.it's working fine.but once set autocomplete source equal null after set autocomplete source years array did not work.how solve problem?

                      $("#year").blur(function() {                                 var keyevent = $.event("keydown");                                 keyevent.keycode = $.ui.keycode.enter;                                 $(this).trigger(keyevent);                                 // stop event propagation if needed                                 return false;                             }).autocomplete({                                 autofocus : true,                                 source : years,                                 selectfirst : true,                                 select : function(event, ui) {                                     variableyear = (ui.item.lable);                                   }                             }); 

code clear source data:

$("#year").autocomplete('option', 'source', null); 

try setting empty array source:

$("#year").autocomplete({source: []}); 

or

$("#year").autocomplete('option', 'source', []); 

Comments

Popular posts from this blog

.htaccess - htaccess convert request to clean url and add slash at the end of the url -

php - facebook and github login HWIOAuthBundle and FOSUserBundle in Symfony2.1 -

hadoop - Sqoop installation export and import from postgresql -