Select2: how to set data after init?

后端 未结 7 1850
醉梦人生
醉梦人生 2021-02-06 22:33

I need to set an array of data after initializing select2. So I want to make something like this:

var select = $(\'#select\').select2({});
select.data([
  {id: 1         


        
7条回答
  •  醉梦人生
    2021-02-06 22:56

    For v4 you'll have to destroy and reconstruct select2 with updated data. Check https://github.com/select2/select2/issues/2830

提交回复
热议问题