Upgrade _jquery for previously written jquery paging

Source: Internet
Author: User

Previously written pagination used for a long time, but in addition to the page when the page is sometimes to pass some other parameters, the previous operation to put the parameters of the transfer to hide hidden, paging in out, so more trouble, today nothing, repackaged a bit

Just go to the code.

CSS used 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;
}


Pagination Code:

(function ($) {var pagefunc = function Pagefunc () {} $. Pagefunc = function (total, PageSize, Curpagenum, funurl,paramstr) {if (PageSize = "" | | PageSize = = NULL | | PageSize = = undefined) {PageSize = +} if (Curpagenum = = "" | | Curpagenum = = NULL | |
Curpagenum = = undefined) {curpagenum = 1;} var hasparam=true; if (Paramstr = = "" | | PARAMSTR = = NULL | | Paramstr = = undefined) {Hasparam = false; The total number of pages calculated totals = parseint (sum); Total record number PageSize = parseint (PageSize); Display number per page Curpagenum = parseint (curpagenum);
Current page//total pages var allpage = Math.floor (total/pagesize);

If (total% PageSize!= 0) {allpage++;} var navhtml = "<ul style=" margin:0

0 0 0; ' class= ' pagination ' > ';
if (curpagenum <= 0) curpagenum = 1; if (Allpage > 1) {if (Curpagenum!= 1) {//Handle front page connection var home=1; if (hasparam) {home=home+ "," +PARAMSTR;} navhtml = "&l
T;li><a href= ' javascript: + Funurl + ' ("+home+") ' >|<</a></li> ';} if (Curpagenum > 1) {var previous=parseint (Parsei)NT (Curpagenum)-1); if (hasparam) {previous=previous+ "," +paramstr}//working on the connection on the previous page navhtml + = "<li><a href= ' javascript:" +funurl+ "(" +
previous+ ") ' ><<</a></li> ';

else {navhtml = "<li class= ' disabled ' ><a><<</a></li>";}
var currint = 5; for (var i = 0; I <= i++) {//total display of up to 10 page numbers, front 5, 5 if (Curpagenum + i-currint) >= 1 && (curpagenum + i-currint) <= allpage) if (Currint = i) {//Current page processing navhtml + = "<li class= ' active ' ><a>" + Curpagenum +
"<span class= ' sr-only ' > (current) </span></a></li>"; else {//General page processing var n = parseint (parseint (curpagenum) + parseint (i)-parseint (Currint)); var nstr=n; if (hasparam) {NST
R=nstr+ "," +PARAMSTR;
} navhtml + = "<li><a href= ' javascript: + Funurl +" ("+nstr+") ' > ' + n + ' </a></li> ';}} if (Curpagenum < Allpage) {//Process next page link var next=parseint (parseint (curpagenum) + 1); if (Hasparam) {next=next+ "," +param
STR;} navhtml + = "<li><a href= ' javascript: + Funurl +" ("+next+") ' >>></a></li> ';}

else {navhtml + = "<li class= ' disabled ' ><a>>></a></li>";} if (curpagenum!= allpage) {var last=parseint (allpage); if (Hasparam) {last=last+ ", +paramstr;} navhtml =" <li>&l
T;a href= ' javascript: + Funurl + ' ("+last+") ' >>|</a></li>}} if (parseint (allpage)!=0) {navhtml = "<li><a>" + Curpagenum + "/" + Allpage + "</a></li> &nb
sp; ";}
navhtml+= "</ul>";
return navhtml;

}; }) (JQuery);

Call Method:

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

function AA (CURPAGE,PARAM1,PARAM2) {
if (curpage = = "" | | Curpage = = NULL | | Curpage = = undefined) {
curpage = 1;
}
var pagesize = 5;
var paramstr= "";
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.