本帖最後由 carlkyo 於 2018-6-5 08:37 編輯
回覆 9# 清仔
many thanks- $("#select2").select2({
- ajax: {
- url: "data.php",
- type: "post",
- dataType: 'json',
- delay: 250,
- data: function (params) {
- return {
- searchTerm: params.term
- };
- },
- processResults: function (res) {
- return {
- results: res
- };
- },
- cache: true
- }
- });
複製代碼 試左好多得呢個可以presetset到- var option = new Option(option, value, true, true);
- $('#select2').append(option).trigger(‘change’);
複製代碼 可能要用 initSelection method |