mar*_*kle 7 jquery jquery-select2
使用select2插件时出现以下错误initSelection.
Error: Uncaught Error: No select2/compat/initSelection 是我得到的错误.
希望有人帮我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]);
});
}
});
Run Code Online (Sandbox Code Playgroud)
joo*_*ost 23
Select2 v3.5.2使用该initSelection方法.Select2 v4有不同的方法.
有关如何升级(initSelection以及其他内容)的信息,请参阅https://select2.github.io/announcements-4.0.html#removed-initselection.
| 归档时间: |
|
| 查看次数: |
12729 次 |
| 最近记录: |