Code Monkey home page Code Monkey logo

paginathing's Introduction

Paginathing

Paginate Everything (support BootstrapCSS 5)

a dead-simple jQuery plugin for paginate your html elements. DEMO

How does the plugin work?

Originally paginathing.js hide all your selector's children DOM. Then shows the DOM based on active page by using jQuery .show()

Requirements

  • jQuery

Usage

Your html markup (example)

<div class="panel panel-primary">
	<div class="panel-heading">
		<h3 class="panel-title">List of item.</h3>
	</div>
	<ul class="list-group">
		<li class="list-group-item"> Your Item 1</li>
		<li class="list-group-item"> Your Item 2</li>
		<li class="list-group-item"> Your Item 3</li>
		<li class="list-group-item"> Your Item 4</li>
		<li class="list-group-item"> Your Item 5</li>
		<li class="list-group-item"> Your Item 6</li>
	</ul>
</div>
</div>

Include jQuery & paginathing first

<!-- jQuery first -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<!-- paginathing.min.js -->
<script
  type="text/javascript"
  src="https://cdn.jsdelivr.net/gh/alfrcr/paginathing/dist/paginathing.min.js"
></script>

Initialize

<!-- Your script -->
<script type="text/javascript">
  jQuery(document).ready(function ($) {
    $(".list-group").paginathing({
      perPage: 2,
      containerClass: "panel-footer",
    });
  });
</script>

Available Options

{
  // show item per page
  perPage: 10,
  // Limiting your pagination number.
  // Value could be boolean or positive integer.
  limitPagination: false,
  // Enable previous and next button
  prevNext: true,
  // Enable first and last button
  firstLast: true,
  // Previous button text
  prevText: '&laquo;',
  // Next button text
  nextText: '&raquo;',
  // "First button" text
  firstText: 'First',
  // "Last button" text
  lastText: 'Last',
  // Extend default container class
  containerClass: 'pagination-container',
  // Extend default <ul> class
  ulClass: 'pagination',
  // Extend <li> class
  liClass: 'page-item',
  // Extend <a> css class
  linkClass: 'page-link',
  // Active link class
  activeClass: 'active',
  // disabled link class,
  disabledClass: 'disable',
  // class or id (eg: .element or #element). append the paginator after certain element
  insertAfter: null,
  // showing current page number of total pages number, to work properly limitPagination must be true
  pageNumbers: false,
}

License

paginathing.js is licensed under MIT

paginathing's People

Contributors

alfrcr avatar mattia1993 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

paginathing's Issues

Provide Filter(Search) Fearture.

The pagination is very simple, easy to use and understand. same like that can you add the search the table data as Filter. It will be more powerful. Just said as a suggestions.

Thanks.

Blank pages when setting limitPagination/how to hide pages?

@alfrcr

I'm having an issue where if I set the limitPagination param then it's displaying that amount of pages regardless if there is that much information available but if there is more information then those pages generate normally.

I'm building a manga website and I'd like to use pagination on the chapter selection since some manga have a great number of chapters. This information is pulled from a mysql database so each manga can have a different number of chapters which is dynamically generated. Thus I'd like only to show a max of 10 pages at once and not generate more pages than necessary.

This is what I have.

<!-- Your script -->
    <script type="text/javascript">
        jQuery(document).ready(function($){
            $('#chapter-list').paginathing({
                perPage: 10, // show item per page
                limitPagination: 10,
                containerClass: 'pagination-container',
                insertAfter: '#chapters'
            })
        });
    </script>

This is the output. As you can see after page 1 the rest are blank.

Page 1
image

Page 2
image

However if you set limitPagination: false then it appears like this which is expected.

image

Basically I'm trying to avoid something like this.

image

So I want to hide the pages after a certain number like 10.

image

Do you think you can help me figure out how to hide the pages after a certain number until clicked?

Too many pages displayed when limitPagination is larger than calculated number of pages

There is a use case where the max page count calculation is incorrect.

  • there is a limitPagination
  • the limitPagination is larger than the total number of available pages (number of rows/pageSize).

I discovered this when I had limitPagination set to 5 for a table with 352 rows and a drop down allowing page size to change : 10, 20, 50, 100. When the page size was set to 100, the number of actual pages was 4 (totalRows/pagesize). This resulted in a pager with 5 pages and the 5th page is blank.

Work around for this: in my ddl change function to redraw the paginathing I would calculate var pagecount = Math.ceil(number of items/page size)
if (pagecount < limitPagination)
set the limitPagination to 0 for the paginathing redraw so I would not get empty pages.
else
use my original limitPagintion of 5

Release a tag of the library

It will be very usefull for other developers that include this library in their projects to release a tag that identifies the actual version of the libraries with the new features.

limitPagination: 9, has a bug

start = _self.currentPage - Math.ceil(limit / 2) ;
modified:
start = _self.currentPage - Math.ceil(limit / 2) + 1;

Add a license

No license at all means "all rights reserved", means "no rights at all". I have modified your code to be pure JS and would like to use it in LibreOffice's help. Unfortunately, no license means I cannot do it.
The plugin you got inspiration from uses Apache 2.0: http://esimakin.github.io/twbs-pagination/#license so I guess you could use it as well.

So you can include a LICENSE file like so: https://github.com/krisk/Fuse/blob/master/LICENSE
...and a mention in the .js file header like so: https://github.com/krisk/Fuse/blob/master/dist/fuse.js

Thank you in advance.

How to go correctly to list page?

How to go correctly to list page?

i have a problem when i go back to the list page with paginathing.

Let me explain the situation.

There are 15 articles.
I made list page with paginathing.

i controlled the paginathing like this..
{
Page: 10,
limitPagination: 2
}

first page is ok,
second page, there are 5 titles in the list.

When i click the list button on article detail view at second page of pagination, ((Page 2/2))
it goes the list at first page. ((Page 1/2))

But i'd like to go just back page: To second page of pagination!

(i read 15th article at second page.. and then i click the list button. It should be second page of pagination )

How can i control this problem?

do you have those kinds of tag?
(like..
currentPage or
bootpag: Use template for hrefs: "#pro-page-{{number}}")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.