views:

23

answers:

1

Can someone help me please? I have little knowledge of JS... I tried this example, that brianpeiris wrote.. It worked nicely, but I need two different pagers in the same page. How can I accomplish this?

This code doesn't work, but this is how far I got..

 <script type="text/javascript">
                    var pagination_options = {
                      num_edge_entries: 1,
                      num_display_entries: 8,
                      callback: pageselectCallback,
                      items_per_page:1
                    }
                    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);


                      var items_per_page = pagination_options.items_per_page;
                      var offset = page_index * items_per_page;
                      var new_content = $('#hiddenresult2 div.result2').slice(offset, offset + items_per_page).clone();
                      $('#Searchresult2').empty().append(new_content);
                      return false;

                    }


                    function initPagination() {
                      var num_entries = $('#hiddenresult div.result').length;
                      // Create pagination element
                      $("#Pagination").pagination(num_entries, pagination_options);

                      num_entries = $('#hiddenresult2 div.result2').length;
                      // Create pagination element
                      $("#Pagination2").pagination(num_entries, pagination_options);                          
                    }


                    $(document).ready(function(){      
                      initPagination();
                    });    

A: 

try this:

var pagination_options = {
  num_edge_entries: 2,
  num_display_entries: 8,
  callback: pageselectCallback,
  items_per_page:3
};
var pagination_options2 = {
  num_edge_entries: 2,
  num_display_entries: 8,
  callback: pageselectCallback2,
  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 pageselectCallback2(page_index, jq){
  var items_per_page = pagination_options2.items_per_page;
  var offset = page_index * items_per_page;
  var new_content = $('#hiddenresult2 div.result').slice(offset, offset + items_per_page).clone();
  $('#Searchresult2').empty().append(new_content);
  return false;
}

function initPagination() {
  var num_entries = $('#hiddenresult div.result').length;
  // Create pagination element
  $("#Pagination").pagination(num_entries, pagination_options);

  num_entries = $('#hiddenresult2 div.result').length;
  // Create pagination element
  $("#Pagination2").pagination(num_entries, pagination_options2)
}

  $(document).ready(function(){      
         initPagination();
  });  

feridcelik
Thanks a lot! You saved my day!P.S.I just changed 'div.result' to 'div.result2' in second pager
artur