So let's keep going with our pagination, and right now I'm looking at Handler's dash video and we still
have a couple of hardcoded things in here.
So let's fix this up in the all sales function in Handler's Dash API Duco, we don't want a hard code.
These two things, when we call get all orders patinated.
We want to put in payload page size and payload Dakara page.
So that's the first thing.
And down here, we don't want our current page to always be one.
We want it to be payload that current page.
OK, so that fixes that.
Now let's go back to our old sales page and change our page so as to say five and see how that works.
So it may start off, I guess maybe start.
And let's go back to our Web browser and go to our all sales page, and there are five words perfect.
And here's our passengers now.
We want to make these buttons work or at least get closer to it.
So let's go back to our old sales page.
And here in the pageant function, what I'm going to do is grab everything that has the class pager.
So I want to get I want to select everything from the current dorm that has the class of pager.
And that's pretty simple.
So we'll say let page buttons.
That's just a variable name.
I'm choosing equal document dot, get elements by class name and I'm looking for the class pager with
an hour.
So once I have them let's just look through them for and I'll use J because I've used I already for
J equals zero J is less than page buttons that length J plus plus.
Now every time I loop through this I want to add an event listener so I'll just say Page Button's index
during the add event listener on the click event.
I want to call this function and I'll look at the event, pass that to the code below.
And what I want to do first is say what do they want to go to when I have that ID in the data dash page
attribute.
So I'll just say let the Zyad page equal target.
All right.
Don't get attribute.
And I'm looking for data dash page.
So now I know what page they want to go to and I'll just make sure this works.
Console that log clicked and created a page is desired page and then I'll make a decision here if desired.
Page I'll use two two brackets.
Desired page is greater than zero and desired page is less than or equal to the total number of pages
which has an --.
Then I'll console of this console dialog would go to page desired page.
OK, so if that's all typed properly and it's not because I have length spelled wrong here length.
Now if that's all typed properly those buttons should at least write to the console.
So let's go make stop Mixter.
Go back to our Web browser, open the JavaScript terminal, reload this page.
OK, so far so good.
Let's click on The Less then, which shouldn't work because that's zero clicked and data dash page is
perfect.
Now let's try the this one to go to the next page clicked and data pages two would go to page two and
let's try this one page for clicked and data dash pages for Perfect.
So now we have a means of actually doing something when we click on the buttons and making sure that
we do exactly what we want to navigate to the appropriate page in the list of pages.