Load values in select2 multiselect

前端 未结 2 1925
猫巷女王i
猫巷女王i 2021-01-05 10:23

I\'m using select2 in place of search box.

Here i\'m using to load countries values like this

$(\"#countries\").select2({
    multiple:          


        
2条回答
  •  萌比男神i
    2021-01-05 10:44

    I just use this http://ivaynberg.github.io/select2/#event_ext_change link and use the trigger function to load the values

    $.getJSON('/dataprovider?data=fetchCountriesForm', function(opts) {
            parent.parent.parent.showLoader();
            if (opts) {
                $("#countries").val(opts).trigger("change");
            } 
    

    This trick load the value in the select box.

提交回复
热议问题