I'm using Select2JS 4.0.5 with PHP and jQuery 3.2.1. jQuery is included first, then right after that select2js then after that the rest of JS libraries. My code
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;
}));
}
});
}
});
}
I keep getting Error: No select2/compat/inputData
Similar questions said that if I include the full version instead and this error will be fixed. I if I do that, the error would become
TypeError: $(...).select2(...) is not a function
I'm using Select2JS 4.0.5 with PHP and jQuery 3.2.1. jQuery is included first, then right after that select2js then after that the rest of JS libraries. My code
I keep getting
Error: No select2/compat/inputDataSimilar questions said that if I include the full version instead and this error will be fixed. I if I do that, the error would become
TypeError: $(...).select2(...) is not a function