问题描述:

i'm using JQuery pagination to paginate some div result.

What i've done is:

<script type="text/javascript">

$(function() {

var optInit = getOptionsFromForm();

$("#Pagination").pagination(<?php echo $num_result;?>, optInit);

});

function pageselectCallback(page_index, jq){

var items_per_page = 10;

var max_elem = Math.min((page_index+1) * items_per_page, <?php echo $num_result;?>);

$('div[id^="page"]').hide();

for(var i=page_index*items_per_page;i<max_elem;i++){

$('#page'+i).show();

}

return false;

}

function getOptionsFromForm(){

var opt = {callback: pageselectCallback,prev_text :'Pagina precedente',next_text:'Pagina successiva',num_display_entries:10,num:2};

return opt;

}

</script>

<div id="result_pagin">

<?php for($i=0;$i<$num_result;$i++){?>

<div id="page<?php echo $i;?>

.

.

.

</div>

<?php }?>

</div>

<div id="Pagination" class="pagination">

</div>

What i need to do is to show pagination panel before result_pagin div and at the end, and i need to add, in that panel, first page and end page buttons. is possible? can someone help me? Thanks!

网友答案:
<div id="Pagination" class="pagination">
  <a id="pgstart" href="#page1">Page 1</a>
  <a id="pgend></a>
</div>

<div id="result_pagin">
<!--...-->
</div>

<script>
  var pgend = (<?php echo $num_result;?> / 10);
  $("#pgend").attr("href", "#page"+pgend);
</script>
相关阅读:
Top