I have a problem with the Select2 drop-down not keeping the list of results after a search is done and a selection is made.
So I would like to know how to prevent the list from disappearing or to add it back to the list. I am using AJAX to get the data based on what the user has searched for.
Below is my code sample
$('.Occupation').select2({
placeholder: 'Select Occupation',
minimumInputLength: 3,
dataCache: self.occupationResultData(),
ajax: {
url: '/Quote/SearchOccupation',
data: function (params) {
var query = { keyword: params.term }
return query;
},
dataType: 'json',
processResults: function (data) {
self.occupationResultData(self.MapOccupationSearchResults(data));
return {
results: self.occupationResultData()
};
},
delay: 750
}
});