1
votes

I have used this Pagination library - jQuery Pagination

Now what I am doing is, generating table of data on clicking on 'Generate button', which fires an ajax call

$.ajax({
   success:
      var total_page = Math.ceil(result['NumRow']/result['PageSize']);
      var page_num = result['PageNum'];
      displaypage(page_num, total_page)
});

From above ajax call I am getting the number of rows and pagesize(no. of rows to display perpage), so dividing it I am getting the number of pages to display on pagination bar. It works fine for the first time. But when another ajax call fires and if this time there are less no. of rows then it should update the pagination bar with less page. but it is not updating. Code for display page:

function displaypage(page, total){
    $('#pagination-demo').twbsPagination({
        startPage: page,
        totalPages: total,
        visiblePages: 7,
        onPageClick: function (event, page) {
            //Some ajax call
    });
}

For first ajax call pagination bar shows correct no. of pages. But for another ajax call it does not change. It stays same. How can I update the pagination bar?

1

1 Answers

1
votes

http://jsfiddle.net/1gL686dz/

in function displaypage() add to top:

$('#pagination-demo').twbsPagination('destroy');