Issue with the jQuery pagination
I'm working on a page that has pagination and 3 different types of sorting. When the page is loaded, the pagination works fine, but, when i go to page 2 and then i choose one ordenation, the page 2 remains as index.
The itens of page are inside of lists and divs tags.
here's the code:
<script>
var quantItens;
var hide;
var paginated;
function pageselectCallback(page_index, jq){
var order = document.getElementById('order').value;
var new_content = jQuery('#Searchresult div.'+order+' ol.list-videos:eq('+page_index+')').clone();
$('#videos').empty().append(new_content);
document.getElementById('mainVideo').src = document.getElementById('Video'+(page_index*6)).src;
$('#mainName').empty().append($('#Name'+(page_index*6)).clone());
$('#mainResumo').empty().append($('#Resumo'+(page_index*6)).clone());
$('#mainDetails').empty().append($('#Details'+(page_index*6)).clone());
return false;
}
function initPagination() {
// count entries inside the hidden content
var order = document.getElementById('order').value;
var num_entries = jQuery('#hiddenresult div.'+order).find('ol.list-videos').length;
quantItens = jQuery('#hiddenresult div.'+order).find('li.videos-list').length;
var new_content = jQuery('#hiddenresult').clone();
$('#Searchresult').append(new_content);
// Create content inside pagination element
$("#Pagination").pagination(num_entries, {
callback: pageselectCallback,
items_per_page:1 // Show only one item per page
});
}
function initPaginationCustom() {
// count entries inside the hidden content
var order = document.getElementById('order').value;
var num_entries = jQuery('#hiddenresult div.'+order).find('ol.list-videos').length;
quantItens = jQuery('#hiddenresult div.'+order).find('li.videos-list').length;
var new_content = jQuery('#Searchresult div.'+order+' ol.list-videos:eq('+0+')').clone();
$('#videos').empty().append(new_content);
document.getElementById('mainVideo').src = document.getElementById('Video0').src;
$('#mainName').empty().append($('#Name0').clone());
$('#mainResumo').empty().append($('#Resumo0').clone());
$('#mainDetails').empty().append($('#Details0').clone());
return false;
}
function alterOrder(){ //called when the sorting is choosed
initPaginationCustom();
}
Anyone know how I can change the index of paging?