Does jQuery autocomplete work with a dynamic array as source

前端 未结 3 1481
执念已碎
执念已碎 2021-02-14 21:04

I am currently trying to create an autocomplete with a source that is stored in a javascript variable but this variable can be updated by another function. So, what I would like

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-14 21:44

    Just add a reset call to auto-complete in you addToTags function:

    var addToTags = function(str){
       availableTags.push(str);
       $( "#tags" ).autocomplete({
           source: availableTags
       });
    }
    

提交回复
热议问题