In this first part of a three-part series, I provide you with a brief introduction to using the main features offered by the Quick Pagination jQuery plug-in. You'll appreciate many of its features, particularly its flat learning curve.
Introducing the Quick Pagination jQuery Plug-in - Setting the stage for the Quick Pagination jQuery plug-in (Page 2 of 4 )
Since my purpose here is to demonstrate how to use the Quick Pagination plug-in with a decent variety of HTML elements, first I’m going to develop an example that will show how to use the plug-in for paginating a bunch of paragraphs with minor effort.
Having explained my plan, now it’s time to write some functional code, right? So, here’s the sample web page that I’m going to use for putting the plug-in into action. Look at its definition, please:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<title>jQuery Quick Pagination using paragraphs and the showcounter parameter</title>
<style type="text/css">
body {
padding: 0;
margin: 0;
background: #fff;
font: 1em Arial, Helvetica, sans-serif;
color: #000;
}
#wrapper {
width: 960px;
margin: 0 auto;
background: #f0f0f0;
}
#header, #content, #footer {
padding: 30px;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
<h1>jQuery Quick Pagination using paragraphs</h1>
<h2>Header section</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
<div id="content">
<h2>Main content section</h2>
<div id="datacontainer">
<p>This is the first paragraph that will be paginated with Quick Pagination jQuery plug-in.</p>
<p>This is the second paragraph that will be paginated with Quick Pagination jQuery plug-in.</p>
<p>This is the third paragraph that will be paginated with Quick Pagination jQuery plug-in.</p>
<p>This is the fourth paragraph that will be paginated with Quick Pagination jQuery plug-in.</p>
<p>This is the fifth paragraph that will be paginated with Quick Pagination jQuery plug-in.</p>
</div>
</div>
<div id="footer">
<h2>Footer section</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
</body>
</html>
As you can see, this sample XHTML document is composed of the classic header, main content and footer sections, which have been provided with a basic visual style. So far, this shows nothing particularly interesting, except for the fact that the content area has an inner div identified as “datacontainer,” which includes a group of paragraphs.
As you’ll realize, if the page is tested in its current state, the paragraphs will be displayed in one row down the page, following the normal rendering flow. However, there will be cases where text displayed in the form of paragraphs, lists, and so forth will be pulled directly from a database, which requires the implementation of a pagination mechanism to make the whole navigation process friendlier and more accessible.
Here’s where the Quick Pagination plug-in comes into play. It can be used for reorganizing the previous paragraphs in nicely paginated chunks, instead of forcing you to have a monolithic block of text.
Thus, now that the previous paragraphs are ready to be used with the Quick Pagination plug-in, in the next section I’m going to create a small segment of JavaScript code that will put the plug-in to work.
To see how this will be done, click on the link below and keep reading.