Commit 0b22d46f authored by Mat's avatar Mat

pagination wip..

parent 936988a3
......@@ -219,20 +219,44 @@
*/
let pageNav = document.querySelector('nav#pagenav ul.pagination');
//let pageItem = document.createElement('li');
//pageItem.classList.add('page-item');
//pageNav.appendChild(pageItem);
AJAX('GET', Routing.generate('api_membre_read_paginate'), function(request)
{
pageNav.innerHTML = null;
let json = JSON.parse(request.responseText);
let total = json.length;
let perPage = paginate.step;
console.log('parPage:' + perPage + ' total:' + total);
if (total > perPage) {
//console.log('parPage:' + perPage + ' total:' + total);
if (total > perPage)
{
let nbPages = total % perPage;
console.log(nbPages + ' pages');
//console.log(nbPages + ' pages');
currentPage = paginate.page;
//console.log('page courante: '+ currentPage);
for (var i = 1; i <= nbPages; i++)
{
let pageItem = document.createElement('li');
pageItem.classList.add('page-item', (i === currentPage) ? 'active' : null);
let pageItemChild = document.createElement((i === currentPage) ? 'span' : 'a');
pageItemChild.classList.add('page-link');
pageItemChild.textContent = i;
if (i !== currentPage) {
paginate.page = i;
pageItemChild.addEventListener('click', function(e)
{
console.log(paginate);
reloadTableMembre(paginate);
});
}
pageItem.appendChild(pageItemChild);
pageNav.appendChild(pageItem);
}
} else {
let nbPages = 1;
console.log(nbPages + ' seule page');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment