Hello everyone,
I'm grappling with an issue involving a select box in a web form that utilizes Select2 with Ajax remote data (https://select2.org/data-sources/ajax) to search for partners in Odoo 16 Website. The stumbling block is the error I'm currently facing:
Uncaught Javascript Error > Option 'ajax' is not allowed for Select2 when attached to a select element.
JS Code:
$(document).ready(function() {
$("#partner_select").select2({
ajax: {
url: '/ms_om/get_partner_names',
dataType: 'json',
delay: 250,
data: function(params) {
return {
search: params.term,
type: 'partner_search',
};
},
processResults: function(data) {
return {
results: $.map(data, function(partner) {
return {
id: partner.id,
text: partner.name,
};
}),
};
},
},
cache: true,
placeholder: 'Search for a partner',
minimumInputLength: 3,
});
});
Template:
Any ideas on how to fix this? It's crucial for my web form project. Your insights would be a game-changer!
Thanks a bunch.