2017-06-07 20 views
1

私はDBにajax searhcクエリでselect2を使用しています。すべてがうまくいきますが、少し問題があります。Select2 ajax処理結果

私はデータベース内のIDを見ていると言います。select2に書き込みを開始するとID:111 - レコードが見つかりました - 1行ですが、私が書いた111の2行あります。ここで

はjavascriptのです。結果の

$(".select2-ajax").select2({ 
      minimumInputLength: 1, 
      tags: [], 
      ajax: { 
       url: "ajax/" + uri, 
       dataType: 'json', 
       type: "GET", 
       quietMillis: 50, 
       data: function (term) { 
        return { 
         q: term.term 
        } 
       }, 
       processResults: function (data) { 
        return { 
         results: data 
        }; 
       } 
      } 
     }); 

画面:

enter image description here

期待される結果:

画像上としてではなく、されるだけで111番目のオプションなしで同じ

答えて

0

解決済み、原因となったby tags: []

$(".select2-ajax").select2({ 
      minimumInputLength: 1, 
      ajax: { 
       url: "ajax/" + uri, 
       dataType: 'json', 
       type: "GET", 
       quietMillis: 50, 
       processResults: function (data) { 
        return { 
         results: data 
        }; 
       }, 
       cache: true 
      } 
     }); 
関連する問題