【发布时间】:2018-07-26 04:06:42
【问题描述】:
我将 Select2JS 4.0.5 与 PHP 和 jQuery 3.2.1 一起使用。首先包含 jQuery,然后是 select2js,然后是其余的 JS 库。我的代码
if ($("#company").length > 0){ // The code below works with typeaheadJS
$('#company').select2()({
source: function (query, syncResults, asyncResults) {
$.ajax({
url: "common/search.php",
data: 'query=' + query,
dataType: "json",
type: "POST",
success: function (data) {
asyncResults($.map(data, function (item) {
return item;
}));
}
});
}
});
}
我不断收到Error: No select2/compat/inputData
类似的问题说,如果我包含完整版本,则此错误将得到修复。如果我这样做,错误会变成
TypeError: $(...).select2(...) is not a function
【问题讨论】:
-
同样的问题,你找到解决办法了吗?
-
@MickaelLeger 不,我切换到selectize.github.io/selectize.js
-
好的,这很奇怪我有另一个项目,我在输入上使用 select2 没有问题,但我只是尝试将我的“输入”更改为“选择”,现在它可以工作了
标签: javascript jquery jquery-select2 jquery-select2-4