having JS like:
$(".select2-input").select2({
placeholder: placeholder,
id: function(data){return data.id},
ajax: {
url: "/autocomplete",
datatype: 'json',
data: function (params) {
return {
q: params.term, // search term
page: params.page
};
},
results: function (data) {
return {
results: data.results
};
},
cache: true,
id: function(connection){
console.log(connection);
}
}
});
and results from "/autocomplete" URL like this:
{"results":[{"id":14953,"text":"Dohn Doe"},{"id":15467,"text":"Jane Dohe"}]}
With all of this I can see autocomplete results, but clicking on any results causes no changes!
So I've been trying to implement answer from this question, but with no luck. Probably I just missed/messed something.
Also this line
console.log(connection);
writes nothing to console.
Select2 version is 4.0