JQuery plugin ---- simplePagination.js API

CSS Themes

"light-theme"

"dark-theme"

"compact-theme"

How To Use

Step 1: together with JQuery, include jquery.simplePagination.js in your page:

<< span>scripttype="text/javascript"src="path_to/jquery.js"></>script><< span>scripttype="text/javascript"src="path_to/jquery.simplePagination.js"></>script>
</span></span>

JQuery 1.7.2 or later is recommended. Older versions might work as well, but they are not tested.

Step 2: OPTIONAL - include the CSS file with the 3 default themes

<< span>linktype="text/css"rel="stylesheet"href="path_to/simplePagination.css"/>
</span>

If you skip this step, you will need to define your own styles or use Bootstrap.

Step 3: call the function on your pagination placeholder:

$(function(){    $(selector).pagination({items:100,itemsOnPage:10,cssStyle:'light-theme'});});

If necessary, you can specify the number of pages directly, via "pages" parameter, instead of "items" and "itemsOnPage" which are used by the plugin to automatically calculate the number of pages.

Available options

itemsIntegerDefault: 1Total number of items that will be used to calculate the pages.
itemsOnPageIntegerDefault: 1Number of items displayed on each page.
pagesIntegerOptionalIf specified, items and itemsOnPage will not be used to calculate the number of pages.
displayedPagesIntegerDefault: 5How many page numbers should be visible while navigating.
Minimum allowed: 3 (previous, current & next)
edgesIntegerDefault: 2How many page numbers are visible at the beginning/ending of the pagination.
currentPageIntegerDefault: 1Which page will be selected immediately after init.
hrefTextPrefixStringDefault: "#page-"A string used to build the href attribute, added before the page number.
hrefTextSuffixStringDefault: empty stringAnother string used to build the href attribute, added after the page number.
prevTextStringDefault: "Prev"Text to be display on the previous button.
nextTextStringDefault: "Next"Text to be display on the next button.
labelMapArrayDefault: empty arrayA collection of labels that will be used to render the pagination items, replacing the numbers.
ellipsePageSetBooleanDefault: trueWhen this option is true, clicking on the ellipse will replace the ellipse with a number type input in which you can manually set the resulting page.
cssStyleStringDefault: "light-theme"The class of the CSS theme.
selectOnClickBooleanDefault: trueSet to false if you don't want to select the page immediately after click.
onPageClick(pageNumber, event)FunctionOptionalFunction to call when a page is clicked.
Page number and event are optional parameters.
onInitFunctionOptionalFunction to call when the pagination is initialized.

Available methods

selectPage - Select a page based on page number.

$(function(){    $(selector).pagination('selectPage',pageNumber);});

prevPage - Selects the previous page.

$(function(){    $(selector).pagination('prevPage');});

nextPage - Select the next page.

$(function(){    $(selector).pagination('nextPage');});

getPagesCount - Returns the total number of pages.

$(function(){    $(selector).pagination('getPagesCount');});

getCurrentPage - Returns the current page number.

$(function(){    $(selector).pagination('getCurrentPage');});

disable - Disables pagination functionality.

$(function(){    $(selector).pagination('disable');});

enable - Enables the pagination after it was previously disabled.

$(function(){    $(selector).pagination('enable');});

destroy - Visually destroys the pagination, any existing settings are kept.

$(function(){    $(selector).pagination('destroy');});

redraw - The pagination is drawn again using the existing settings. (useful after you have destroyed a pagination for example)

$(function(){    $(selector).pagination('redraw');});

updateItems - allows to dynamically change how many items are rendered by the pagination

$(function(){    $(selector).pagination('updateItems',100);});

updateItemsOnPage - allows to dynamically change how many items are rendered on each page

$(function(){    $(selector).pagination('updateItemsOnPage',20);});

drawPage - takes a page number as a parameter and it sets the "currentPage" value to the given page number and draws the pagination

$(function(){    $(selector).pagination('drawPage',5);});JQuery  plugin  ----   simplePagination.js  API

转载于:https://www.cnblogs.com/piaopiaoqun/p/6104699.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值