Pagination fonctionnelle dans planets
This commit is contained in:
parent
8d4456bae6
commit
b32e65c82b
@ -61,23 +61,31 @@ function remplissage(results){
|
|||||||
let previousButton = `<button id="prevButton">Page précédente</button>`;
|
let previousButton = `<button id="prevButton">Page précédente</button>`;
|
||||||
let currentButton = `${currentPage}`;
|
let currentButton = `${currentPage}`;
|
||||||
let nextButton = `<button id="nextButton">Page suivante</button>`;
|
let nextButton = `<button id="nextButton">Page suivante</button>`;
|
||||||
if(!firstPage) {
|
|
||||||
planetes.innerHTML += previousButton;
|
planetes.innerHTML += previousButton;
|
||||||
console.log(document.getElementById("prevButton"));
|
planetes.innerHTML += currentButton;
|
||||||
|
planetes.innerHTML += nextButton;
|
||||||
|
|
||||||
|
if(firstPage){
|
||||||
|
document.getElementById("prevButton").hidden = true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
document.getElementById("prevButton").hidden = false;
|
||||||
|
}
|
||||||
|
if(lastPage){
|
||||||
|
document.getElementById("nextButton").hidden = true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
document.getElementById("nextButton").hidden = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("prevButton").addEventListener("click", () => {
|
document.getElementById("prevButton").addEventListener("click", () => {
|
||||||
api_call(previousUrl, remplissage);
|
api_call(previousUrl, remplissage);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
planetes.innerHTML += currentButton;
|
|
||||||
if(!lastPage) {
|
|
||||||
planetes.innerHTML += nextButton;
|
|
||||||
document.getElementById("nextButton").addEventListener("click", () => {
|
document.getElementById("nextButton").addEventListener("click", () => {
|
||||||
api_call(nextUrl, remplissage);
|
api_call(nextUrl, remplissage);
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
api_call(API_URL + "/planets", remplissage);
|
api_call(API_URL + "/planets", remplissage);
|
||||||
|
Loading…
Reference in New Issue
Block a user