Tôi nhận được lỗi sau khi sử dụng plugin select2 trên initSelection
.select2 - lỗi initselection
Error: Uncaught Error: No select2/compat/initSelection
là lỗi tôi nhận được.
Hy vọng ai đó giúp tôi phân loại sự cố inistselection
.
JS:
$(".doctor_id_pat").select2({
placeholder: "Search Users",
minimumInputLength: 2,
ajax: {
url: "/listallergiesajax",
dataType: 'json',
data: function(term) {
return {
q: term
};
},
results: function(data, page) {
return {
results: $.map(data, function(item) {
return {
text: item.text,
id: item.id
}
})
};
},
},
initSelection: function(element, callback) {
$.ajax("/listallergiesajax", {
dataType: "json"
}).done(function(data) {
callback(data.results[0]);
});
}
});
'$ (". Doctor_id_pat "). Select2 ({});' chọn 2 là gì? – ashkufaraz
Đây là một plugin cho các tùy chọn được chọn. @ashkufaraz –
Không được chấp nhận trong Select2 4.0. Điều này đã được thay thế bằng một tùy chọn khác và chỉ có sẵn trong các bản dựng đầy đủ của Select2. – Hackerman