Below is my code copied from https://select2.github.io/examples.html to load remote data via Select2 in my Asp.net MVC 4 project, which displayed in a Bootstap Modal dialog, however, it always shows "params.page" is undefined, it do worked if I put a "page:1" there. What's the problem?
$("#ReportToEmployeeName").select2({
placeholder: "Select Report To",
ajax: {
url: 'myurl ',
dataType: 'json',
delay: 250,
data: function (params) {
console.log(params);
return {
term: params.term, // search term
page: params.page //Undefined error here
//page: 1 // do worked, but then pagination will not work
};
},
processResults: function(data, params) {
params.page = params.page || 1;
return {
results: data.Results,
pagination: {
more: (params.page * pageSize) < data.Total
}
};
},
cache: true
},
//escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
minimumInputLength: 1,
allowClear: true,
//templateResult: formatRepo, // omitted for brevity, see the source of this page
//templateSelection: formatRepoSelection // omitted for brevity, see the source of this page
});