Select2 - use JSON as local data

后端 未结 3 960
暖寄归人
暖寄归人 2020-12-14 09:53

I can get this to work...

var options = [{id: 1, text: \'Adair, Charles\'}]  
$(\'#names\').select2({
    data: options,
})

But i cant work

3条回答
  •  自闭症患者
    2020-12-14 10:25

    Just to add. This also worked for me:

    HTML:

    
    

    Javascript

    $('#names').select2();
    
    var options = $('#names');
    
    $.each(sampleArray, function() {
        options.append($("

提交回复
热议问题