I Have some problem while using Select2 Jquery Plugin cause its my 1st time use it.
$(".select-class").select2({
ajax: {
url: "{{route('route-next')}}",
dataType: 'json',
type: "POST",
data: function (term, page) {
return {
type: 'type_of_mine',
kelas : kelas,
jurusan : jurusan,
q: term
};
},
results: function (data, page) {
return { results: data.results };
}
},
initSelection: function (item, callback) {
var id = item.val();
var text = item.data('option');
if(id > 0){
var data = { id: id, text: text };
callback(data);
}
},
formatAjaxError:function(a,b,c){return"Not Found .."}
});
but i always got this error message on my console :
jquery.min.js:2 Uncaught Error: No select2/compat/initSelection(…)
By the looks of it, initSelection
has been removed in later versions of Select2.
You can find more information about it's removal and how to fix it here.
Hope that helps!