Ich habe das folgende javascript/jQuery, das Daten von via AJAX einliest. Das funktioniert gut, aber ich kann nicht in der Lage sein, eine Option aus dem Dropdown auszuwählen. Kann mir jemand erklären, was ich falsch gemacht haben ..Ergebnis nicht auswählbar aus select2 dropdown
Das ist etwas mit der ID zu tun ist ..
$(".js-data-example-ajax").select2({
ajax: {
url: "/admin/generator/teams",
dataType: 'json',
delay: 250,
data: function (params) {
return {
q: params.term, // search term
page: params.page
};
},
processResults: function (data, params) {
// parse the results into the format expected by Select2
// since we are using custom formatting functions we do not need to
// alter the remote JSON data, except to indicate that infinite
// scrolling can be used
params.page = params.page || 1;
return {
results: data.items,
pagination: {
more: (params.page * 30) < data.total_count
}
};
},
cache: true
},
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
minimumInputLength: 1,
id: function(data){ return data._id; },
});