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

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

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