Upgrade to jquery paging

Source: Internet
Author: User

Used to write the page for a long time, but in addition to the page paging sometimes to pass some other parameters, the previous operation to put the parameters of the hidden hidden, paging in the removal, so more trouble, today nothing, re-packaged a bit

Go directly to the code.

CSS uses the style of pagination in bootstrap

. Pagination-lg > Li:first-child > A,.pagination-lg > Li:first-child > Span{Border-bottom-left-radius:6px;Border-top-left-radius:6px;}. Pagination-lg > Li:last-child > A,.pagination-lg > Li:last-child > Span{Border-top-right-radius:6px;Border-bottom-right-radius:6px;}. pagination-sm > li > A,.pagination-sm > li > Span{padding:5px 10px;font-size:12px;}. pagination-sm > Li:first-child > A,.pagination-sm > Li:first-child > Span{Border-bottom-left-radius:3px;Border-top-left-radius:3px;}. pagination-sm > Li:last-child > A,.pagination-sm > Li:last-child > Span{Border-top-right-radius:3px;Border-bottom-right-radius:3px;}. Sr-only{position:Absolute;width:1px;Height:1px;padding:0;margin:-1px;Overflow:Hidden;Clip:rect (0, 0, 0, 0);Border:0;}

Paging Code:

(function ($) {    varPagefunc =functionPagefunc () {} $. Pagefunc=function(Total, PageSize, Curpagenum, funurl,paramstr) {if(PageSize = = "" | | PageSize = =NULL|| PageSize = =undefined) {PageSize= 10; }        if(Curpagenum = = "" | | Curpagenum = =NULL|| Curpagenum = =undefined) {Curpagenum= 1; }        varhasparam=true; if(Paramstr = = "" | | Paramstr = =NULL|| Paramstr = =undefined) {Hasparam=false; }        //Calculate Total PagesTotal = parseint (total);//Total Record CountPageSize = parseint (PageSize);//number of displays per pageCurpagenum = parseint (curpagenum);//Current Page        //Total Pages        varAllpage = Math.floor (Total/PageSize); if(total% PageSize! = 0) {Allpage++; }        varnavhtml = "<ul style= ' margin:0 0 0 0; ' class= ' pagination ' > '; if(Curpagenum <= 0) Curpagenum= 1; if(Allpage > 1) {            if(Curpagenum! = 1) {                //Handling Home Page Connections                varHome=1; if(hasparam) {Home=home+ "," +Paramstr; } navhtml+ = "<li><a href= ' javascript:" + Funurl + "(" +home+ ") ' >|<</a></li> '; }            if(Curpagenum > 1) {                varPrevious=parseint (parseint (curpagenum)-1); if(Hasparam) {Previous=previous+ "," +Paramstr; }                //Process the previous page of a connectionnavhtml + = "<li><a href= ' javascript:" +funurl+ "(" +previous+ ") ' ><<</a></li> '; }            Else{navhtml+ = "<li class= ' disabled ' ><a><<</a></li>"; }            varCurrint = 5;  for(vari = 0; I <= 10; i++) {                //A total of up to 10 page numbers, front 5, followed by 5                if((Curpagenum + i-currint) >= 1 && (curpagenum + i-currint) <=allpage)if(Currint = =i) {//Current page Processingnavhtml + = "<li class= ' active ' ><a>" + curpagenum + "<span class= ' sr-only ' > (current) </span>< /a></li> "; }                    Else {                        //General page Handling                        varn = parseint (parseint (curpagenum) + parseint (i)-parseint (currint)); varNstr=N; if(hasparam) {nstr=nstr+ "," +Paramstr; } navhtml+ = "<li><a href= ' javascript:" + Funurl + "(" +nstr+ ") ' >" + n + "</a></li>"; }            }            if(Curpagenum <allpage) {                //working with links to the next page                varNext=parseint (parseint (curpagenum) + 1); if(Hasparam) {Next=next+ "," +Paramstr; } navhtml+ = "<li><a href= ' javascript:" + Funurl + "(" +next+ ") ' >>></a></li> '; }            Else{navhtml+ = "<li class= ' disabled ' ><a>>></a></li>"; }            if(Curpagenum! =allpage) {                varlast=parseint (allpage); if(Hasparam) { last=last+ "," +Paramstr; } navhtml+ = "<li><a href= ' javascript:" + Funurl + "(" +last+ ") ' >>|</a></li> '; }        }       if(parseint (Allpage)!=0) {navhtml+ = "<li><a>" + Curpagenum + "/" + Allpage + "</a></li>&nbsp;&nbsp;"; } navhtml+ = "</ul>"; returnnavhtml; };}) (jQuery);

Call Method:

Note: The first parameter must be the value of the current page.

functionAA (curpage,param1,param2) {if(Curpage = = "" | | Curpage = =NULL|| Curpage = =undefined) {Curpage= 1; }        varPageSize = 5; varParamstr= ""; Paramstr=param1+ "," +param2+ "; $.post ("/appdefult/apporder", {"CategoryId":p aram1, "name":p aram2, "curpage": Curpage, "pagesize":p agesize},function (mydata) {var pagehtml= $. Pagefunc (Mydata.total, pagesize, Curpage,"AA", PARAMSTR); $(". Page"). HTML (pagehtml); },"JSON");}

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.