使用 select2 插件时出现以下错误initSelection
.
Error: Uncaught Error: No select2/compat/initSelection
是我收到的错误。
希望有人帮助我整理inistselection
issue.
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]);
});
}
});
Select2 v3.5.2 使用initSelection
方法。 Select2 v4 有不同的方法。
有关如何升级的信息(initSelection
和其他东西)参见https://select2.org/upgrading/migration-from-35#removed-the-requirement-of-initselection https://select2.org/upgrading/migrating-from-35#removed-the-requirement-of-initselection.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)