Bootstrap Paginator Paging plug-in combined with Ajax to achieve dynamic no-refresh paging effect _javascript skills

Source: Internet
Author: User

Bootstrap Paginator Paging plugin download Address:

Downloadvisit Project in GitHub

1. This is the need for pagination page to put the JS function:

<span style= "FONT-SIZE:14PX;" >function Paging (page) { 
$.ajax ({ 
type: "Get", 
URL: "${ctx}/api/v1/user/1/" + (page-1) + "/5", 
DataType: "JSON", 
success:function (msg) { 
...//omitted (query out data) 
} 
}); 
$.ajax ({ 
type: "Get", 
URL: "${CTX}/API/V1/USER/COUNT/1", 
dataType: "JSON", 
success:function ( msg) { 
var pages = Math.ceil (MSG.DATA/5);//Here data contains the total number of 
var element = $ (' #pageUl ');//corresponding to the following UL ID 
var Options = { 
Bootstrapmajorversion:3, 
currentpage:page,//current page 
numberofpages:5,// One page shows several buttons (generate 5 Li in ul) 
totalpages:pages//Total pages 
} 
element.bootstrappaginator (options); 
} </span> 

Page:

<span style= "FONT-SIZE:14PX;" ><ul class= "pagination" id= "Pageul" > 

It's automatically generated inside the *li.

2. The most important and the core is to change their own bootstrap-paginator.js source files , as follows:

<span style= "FONT-SIZE:14PX;" >onpageclicked:function (event, originalevent, type, page) { 
//show the corresponding page and retrieve the newly Built item related to the page clicked before for the event return 
var currenttarget = $ (event.currenttarget); 
Switch (type) {case "a" 
: 
currenttarget.bootstrappaginator ("Showfirst"); 
Paging (page); 
break; 
Last page case 
"prev": 
currenttarget.bootstrappaginator ("showprevious"); 
Paging (page); 
break; 
Case "Next": 
currenttarget.bootstrappaginator ("Shownext"); 
Paging (page); 
break; 
Case "Last": 
currenttarget.bootstrappaginator ("Showlast"); 
Paging (page); 
break; 
Case "page": 
currenttarget.bootstrappaginator ("show", page); 
Paging (page); 
break; 
 

* After you click on the page style out of the call Paging (page) method, where the page source file parameters have been, direct transmission!

Effect: When the style changes, directly take the control page value of the AJAX request to send! Finally, no refresh paging is implemented.

The above is a small set to introduce the Bootstrap Paginator page Plug-ins and Ajax combined to achieve dynamic no refresh paging effect of the relevant knowledge, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.