I trying to create pagination in using Select2 4.0
js code without pagination working good
$("#CatID").select2({
placeholder: "Please type at least 3 characters",
minimumInputLength: 3,
allowClear: true,
ajax: {
url: "/Search",
contentType: "application/json; charset=utf-8",
data: function(params) {
var query = {
term: params.term
};
return query;
},
processResults: function(result) {
return {
results: $.map(result, function(item) {
return {
id: item.id,
text: item.name
};
}),
};
}
}
});
I tried to adding pagination to the following code but it doesn’t work
$("#CatID").select2({
placeholder: "Please type at least 3 characters",
minimumInputLength: 3,
allowClear: true,
ajax: {
url: "/Search",
contentType: "application/json; charset=utf-8",
data: function(params) {
var query = {
term: params.term,
page: params.page || 1
};
return query;
},
processResults: function(data, params) {
params.page = params.page || 1;
return {
results: $.map(data, function(item) {
return {
id: item.id,
text: item.name
},
pagination: {
more: (params.page * 10) < data.count_filtered
}
}),
};
}
}
});