I executing a function like this,
The callback of the pagination plugin here which I assume you are using is defined internally as
opts.callback(current_page, containers);
This is different to the signature of your callback so no it will not work the same.
Apparently the currentPage
parameter of getEntities()
is an object, so adding 1 to it is not a sensible operation. Check with firebug what the type and contents of currentPage
is.
The getEntities
function expects 3 arguments. Here you are passing only 2:
callback: getEntities("Clients/GetClients", formatClientsResult)
Also the second argument needs to be an integer and not another function. And as it is a callback it needs to be defined as such:
callback: function() {
getEntities("Clients/GetClients", 0, formatClientsResult);
}
UPDATE:
The reason you are always getting the same AJAX request is that you always pass 0 to the getEntities
function in the pagination callback.
Try this:
$(".pager").pagination(maxvalues, {
callback: function (new_page_index, pagination_container) {
// Notice how the new_page_index is passed
getEntities("home/GetClients", new_page_index, formatClientsResult);
},
current_page: 0,
items_per_page: 5,
num_display_entries: 5,
next_text: 'Next',
prev_text: 'Prev',
num_edge_entries: 1
});
Try this:
$(document).ready(function() {
var helper = function() {
getEntities("Clients/GetClients", 0, formatClientsResult);
};
helper();
var maxvalues = $("#HfId").val();
$(".pager").pagination(maxvalues, {
callback: helper,
current_page: 0,
items_per_page: 5,
num_display_entries: 5,
next_text: 'Next',
prev_text: 'Prev',
num_edge_entries: 1
});