For the foture me XD : The id field was mismatched BE side (Id (capital I) instead of id). So the field was not found by the plugin. If that happens the select event isn't fired. No error in the console whatsoever. Pretty Meh.
Mar 1, 2023
1
Level 1
Select2 click on item not working
I have a laravel project where i need an autocomplete select that call an API for results. For the frontend task i use Select2 plugin:
$('#userAutoComplete').select2({
placeholder: 'Select an user',
allowClear: true,
ajax: {
type:'POST',
url: path,
dataType: 'json',
delay: 250,
processResults: function (data) {
return {
results: $.map(data.original, function (user) {
return {
text: user.lastname + " " +user.firstname +" ("+user.email+")",
id: user.id
}
})
};
},
cache: false
}
});
This works well while retrieving the results, but then when the dropdown is populated, when i click any option, nothing happens, also hover is not working (not changing color on the results as i hover with the mouse). Also no errors in the console. Im pretty much confused
Level 1
Please or to participate in this conversation.