From the course: Building Full-Stack Applications with HTMX

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Adding pagination

Adding pagination

- [Instructor] We have successfully loaded our products from our database into our frontend view using HTMX. But this is a data table and we should have the ability to page it records in the database beyond what we currently have displayed. So in this video we'll be setting up pagination controls to help us navigate between different record sets in our database. Our product's endpoint already takes care of sending page and limit parameters to fetch a subset of the product's data. So all we need to do is to send the appropriate queries with our pagination controls to fetch the next set of records. To implement this, let's add back to our render function and add our pagination controls. Just going to collapse this and scroll up to our render function. And just under our loop, let us add our pagination controls. To begin, first, let us open a div to all our pagination controls and append it to our HTML templates. Good, next we're going to use utilities from our Mongoose Paginate V2…

Contents