簡體   English   中英

Select2 minimumInputLength在append()之后不起作用

[英]Select2 minimumInputLength Not Working After append()

在我的select2中,我使用minimumInputLength選項在一定長度后開始過濾。

selectExample.select2({
  minimumInputLength: 2
});

但是在使用append()函數動態附加新選項之后,此minimumInputLength選項不起作用。

selectExample.append('<option value="10">Ten</option>');

到底發生了什么事? 有沒有為select2附加新選項的特定方法?

我當前使用的解決方案是重新聲明.select2(),其中包含minimumInputLength選項。

var dynamicOptions=[{ id: 0, text: 'enhancement' }, { id: 1, text: 'bug' }, { id: 2, text: 'duplicate' }, { id: 3, text: 'invalid' }, { id: 4, text: 'wontfix' }];

 $("#select2").select2('data', dynamicOptions);

這就是您需要添加選項的方式

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM