2
我正在使用4.0.0完整版,以便它也支持3.5.2功能。我正在使用query
選項填寫結果。一切工作正常,但是當我從結果中選擇一個項目時,它不顯示它。Select2未顯示所選值
$(document).ready(function() {
$(".select").select2({
minimumInputLength: 1,
query: function (query) {
if (query.term) {
var data = { results: [] }, i, j, s;
for (i = 1; i < 5; i++) {
s = "";
for (j = 0; j < i; j++) { s = s + query.term; }
data.results.push({ id: query.term + i, text: s });
}
query.callback(data);
}
}
});
});
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.full.js"></script>
<select class="select" style="width:300px"></select>
非常感謝 – mahindar