Struggling with pagination when dealing with numerous identical HTML elements within a single file?

I am in the process of creating a web app for a small CTF that will be held at my school. I have designed a webpage to display the problems, but currently they are all lined up in a long row.

This is how it's set up:

    <body class="main-body">

        <div class="body">

            <section class="content">

                <div class="container-asdf"> <!-- This is a grid, assume that this particular element is repeated several times with changes -->
                    <div class="item-a">Test Problem</div>
                    <div class="item-b">Category: Test, Problem</div>
                    <div class="item-c"><button data-toggle="modal" data-target="#exampleModal" type="button" class="btn btn-info">Button</button></div>
                </div>

             </section>
        </div>
    </body>

(I acknowledge that this HTML may not be the most efficient, but it is what I have at the moment)

The div with class "container-asdf" is generated automatically based on the number of problems. Let's say it generates 50 problems, but I only want to display 10 at a time and split them into pages without creating multiple HTML files. How can I achieve this without writing lots of code? My initial idea was to hide some containers and show them as different numbers are selected, which is why I am looking into pagination.

To sum up: I need to display many elements on one page, limit them, and separate them into pages without using multiple HTML files. The HTML is being generated by Flask/Jinja. Any guidance would be appreciated!

Thank you for your assistance!

Answer №1

Have you ever thought about trying out the easyPaginate jQuery plugin for handling pagination? You can check out a live example and setup instructions here.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Navbar is not displaying the React Bootstrap 4 CSS module as intended

Having some trouble changing the color of my navbar. Is there a step I might be missing? Here's the component I'm trying to render: import React from 'react'; import { Nav, Navbar } from 'react-bootstrap'; import styles from ...

Permanent header that clicks into place below the primary fixed header

I've been collaborating with fellow developers on this platform to tackle a persistent issue related to a fixed header. Here is the updated fiddle for reference: http://jsfiddle.net/f95sW/ The Challenge 1) As you scroll down the page, the yellow bl ...

Which event listener in the DOM API should I use to trigger an action when a form field is focused, whether through a mouse click or by tabbing?

My aim is to increase the size of form fields when the cursor focuses on them, either through a mouse click or by tabbing using the keyboard. By utilizing document.activeElement focus, I can identify when the user clicks inside a text input or selects an ...

What are some strategies for ensuring that Plotly JS can adapt its height and width to fit the entire div dynamically, without relying on fixed pixel dimensions?

Is there a way to ensure that Plotly automatically adjusts to the size of the container #myDiv without any noticeable delay when the top button is clicked? This code snippet demonstrates a high delay: var z = [], steps = [], i; for (i = 0; i < 500; i+ ...

Incorporating HTML elements within JSON data

I have validated my JSON Data using JSONLint and here it is: [{ "text": "Products", "data": {}, "children": [{ "text": "Fruit", "data": { "price": "", "quantity": "", "AddItem": "&#43;", "RemoveItem": "&#215 ...

The content in the flex box item with horizontal scroll is overflowing beyond its boundaries

I am working with a flex box container that contains two child elements: a left side and a right side. I want the right side item to have a horizontal scrollbar in order to fit its content. .container { display: flex; overflow: hidden; height: 300 ...

add the AJAX response to the specified div element

I'm currently using an ajax call to retrieve movie data from the IMDb API for 'The Shawshank Redemption'. My goal is to display this data within the designated div element. <div id="movie-data"></div> Here's my current Jav ...

Is there a way to locate the content enclosed within a span tag without any specific class or ID attribute using Selenium with Python?

I have been attempting to utilize Selenium in order to locate the text within a span element that lacks any specific attributes such as class or id for identification. Here is the HTML structure: HTML snippet obtained from inspecting the element in Chrome ...

Modified the component based on the state passed from another component

One issue I'm facing is with my hamburger component in TodoHeader.jsx. It only has a color prop, no className prop. I noticed that when using the ternary operator to change its color, it only takes effect after a page reload. On the other hand, FontAw ...

Utilizing Google+ Snippet and Open Graph Protocol for Enhanced Visibility

I am currently facing an issue with my dynamically built web page where the links shared on Google+ are not showing snippets properly. I have followed the example snippet for article rendering and documentation provided here: https://developers.google.com ...

Scrolling the Html5 canvas smoothly without the need for constant re-rendering

Is it feasible to achieve smooth panning on an HTML5 canvas without the need for rerendering? Are there any examples of code that demonstrate this functionality? Furthermore, is it also possible to apply the same technique for zooming? I am experiencing ...

Excessive padding observed on the right side of the screen when viewed on mobile devices

I am having an issue with my portfolio site where there is a white space on the right side in the mobile view, but only in Chrome. The desktop and Mozilla mobile views are fine. I have attached a screenshot highlighting the problem. Here is the link: Chrom ...

Django was unable to load the static image

Currently, my Django application is hosted on PythonAnywhere. In order to generate a PDF, I am utilizing WeasyPrint which includes an image that should be displayed in the PDF. However, within the error log, I am encountering the message "Failed to load im ...

CSS Trouble with Stacking Order

Seeking assistance with my learning/practice journey, any help is greatly appreciated. Please feel free to point out errors or inefficiencies. I currently have four layers in place: .body .main .main-side .sidebar Here is the design I'm trying to r ...

Challenges encountered with pagination functionality within Datatables integration

I'm encountering a small problem with pagination. When using the "four_button" type, the table appears correctly (with accurate pagination buttons), but clicking on any of the pagination buttons (Next, Previous, etc...) results in an error saying "fnC ...

Discovering the way to retrieve background height following a window resize using jQuery

Is there a way to obtain the background height once the window has been resized? div { background-image: url(/images/somebackground.jpg); background-size: 100% 90%; background-repeat: no-repeat; width: 70%; background-size: contain; ...

Extracting the id of an element using jQuery

The desired outcome is for the code to print the id of the selected div, but it's not working as expected. I've reviewed it multiple times but couldn't pinpoint the error. Any assistance would be greatly appreciated. Here is the HTML: < ...

Using JavaScript to listen for events on all dynamically created li elements

Recently, I've created a simple script that dynamically adds "li" elements to a "ul" and assigns them a specific class. However, I now want to modify the class of an "li" item when a click event occurs. Here's the HTML structure: <form class ...

Display corresponding div elements upon clicking an HTML select option

Is there a way to make a div visible when a corresponding select option is clicked, while hiding others? My JavaScript skills are lacking in this area. CSS #aaa, #bbb, #ccc { display:none; } The HTML (I'm using the same id name for option and d ...

Ways to automatically resize Bootstrap columns to accommodate overflowing elements

Is there a way to make BootStrap 5 columns expand in size when the content inside of them overflows, rather than letting it collide with other elements? https://i.sstatic.net/WIn0F.png The current issue I'm facing is that my columns (purple) allow t ...