The BootstrapPaginator paging plug-in is combined with ajax to achieve the effect of refreshing pages dynamically.

Source: Internet
Author: User
This article mainly introduces the combination of the BootstrapPaginator paging plug-in and ajax to achieve the dynamic and non-Refresh paging effect. It is very good and has reference value. If you are interested, let's take a look at the Bootstrap Paginator paging plug-in:

DownloadVisit Project in GitHub

1. This is the js function for paging pages:

Function paging (page) {$. ajax ({type: "GET", url: "$ {ctx}/api/v1/user/1/" + (page-1) + "/5", dataType: "json", success: function (msg ){.... // omitted (Data queried)}); $. ajax ({type: "GET", url: "$ {ctx}/api/v1/user/count/1", dataType: "json", success: function (msg) {var pages = Math. ceil (msg. data/5); // The total amount of data in the data is var element = $ ('# pageUl'); // corresponding to ul's IDvar options = {bootstrapMajorVersion: 3, currentPage: page, // the current page numberOfPages: 5, // several buttons are displayed on a page (5 li is generated in ul) totalPages: pages // total number of pages} element. bootstrapPaginator (options );}});}

Page:

 
 

    * Automatically generated in li

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

    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 returnvar currentTarget = $ (event. currentTarget); switch (type) {case "first": currentTarget. bootstrapPaginator ("showFirst"); paging (page); break; // Previous 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 ;}},

    * Call the paging (page) method after you click the page style. Here, the parameters in the page source file already exist and are directly transmitted!

    Effect: When the style changes, send an ajax request directly with the page value of the control! Finally, no refreshing paging is implemented.

    The above section describes how to use the Bootstrap Paginator paging plug-in combination with ajax to achieve the effect of refreshing pages dynamically. I hope it will be helpful to you, if you have any questions, please leave a message and the editor will reply to you in time. I would like to thank you for your support for PHP chinnet!

    For more information about how to use the Bootstrap Paginator paging plug-in and ajax to achieve dynamic and refreshing Paginator pages, see the PHP Chinese website!

    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.