jQuery Pagination Plugin

前端 未结 1 1112
执念已碎
执念已碎 2020-11-29 06:08

Hopefully this is something that will be easy to remedy. I\'m having a bit of an issue understanding the jQuery Pagination plugin.

Essentially, all I am trying to d

相关标签:
1条回答
  • 2020-11-29 06:59

    You don't even need to use a for loop, just use jQuery's slice() method and a bit of math.

    I've hosted a working demo on JS Bin: http://jsbin.com/upuwe (Editable via http://jsbin.com/upuwe/edit)

    Here's the modified code:

    var pagination_options = {
      num_edge_entries: 2,
      num_display_entries: 8,
      callback: pageselectCallback,
      items_per_page:3
    }
    function pageselectCallback(page_index, jq){
      var items_per_page = pagination_options.items_per_page;
      var offset = page_index * items_per_page;
      var new_content = $('#hiddenresult div.result').slice(offset, offset + items_per_page).clone();
      $('#Searchresult').empty().append(new_content);
      return false;
    }
    function initPagination() {
      var num_entries = $('#hiddenresult div.result').length;
      // Create pagination element
      $("#Pagination").pagination(num_entries, pagination_options);
    }
    
    0 讨论(0)
提交回复
热议问题