![](/img/trans.png)
[英]create array of dropdown using select2 4.0.3 and disable the options based on other select2 values
[英]select2 get dropdown options array list
我正在使用“ select2-selecting”事件,並希望獲得具有ID和標簽的數組。
我的代碼是:
$('.mySelect').select2({ ... some options}).on("select2-selecting", function(e) {
// I need to get an array with dropdown values
});
我可以使用$(this).select2('data')獲得選擇的值,我可以通過$(this).select2('dropdown');獲得下拉選擇器。 但是如何獲取具有ID的下拉列表數組?
使用'select2-loaded'
事件。 它會在'select2-selecting'
之前觸發,您可以獲得實際的下拉列表。 例
$('.mySelect').on('select2-loaded', function(e) {
dropDownList = e.items.results;
}).on('select2-selecting', function(e) {
console.log(dropDownList);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.