Basically I have implemented a dropdown using select2, and I wired it up with ajax. That all works alright.
However the problem I have, is that I prepopulate some options via html. So what happens when I click on the select2 dropdown, it resets the options and waits for keyboard input. When I type in the keyword, it works as it should.
So is there a way to prevent select2, from clearing the items that were pre-populated whenever it gains focus? I would prefer that it would only get reset, once I actually type something in.
var merchantCategorySelect = $('#merchantCategory');
merchantCategorySelect.select2({
width: '100%',
ajax: {
url: "/admin/offers/not-matched/fetch-categories",
data: function (params, page) {
return {
term: params['term'],
merchantId: merchantCategorySelect.data('merchantid'),
}
}
}
});