The main purpose of this article is to share the Laypage multi-functional JS paging component specific operating methods for your reference, the specific content as follows
PHP section
function index () {
header (' Content-type:text/html;charset=utf-8 ');
Gets the current page number, the default first page, sets the default display bar per page
$nowpage = I (' Get.page ', 1, ' intval ');
$limits = 8;
Gets the total number of bars
$count = M (' Article ')-> where (' status ' =>array (' Egt ', 0))-> count ();
Calculates the total page
$allpage = ceil ($count/$limits);
$allpage = Intval ($allpage);
$lists = M (' Article ')-> where (array (' Status ' =>array (' Egt ', 0))
-> page ($nowpage, $limits)//page method paging C12/>-> order (' createtime desc ')
-> Select ();
Jump paging output
$this-> Assign (' lists ', $lists);
$this-> Assign (' Allpage ', $allpage);
$this-> Assign (' Nowpage ', $nowpage);
$this->display ();
/*//Ajax paging output
$info = Array (' lists ' => $lists, ' allpage ' => $allpage, ' nowpage ' => $nowpage);
$this->ajaxreturn ($info, ' json ');
*/
}
JS Laypage (new version) jump pagination
Paging
laypage ({
cont: ' show_pages ',//Paging container pages
: ' {$allpage} ', //Total pages
skip:true,//Open Hop page
Curr:function () {
var page = ' {$nowpage} ';//Current page (background-acquired)
return page page:1;//back to current page value
} (),
jump:f Unction (E, first) {//triggers a paging callback (after clicking the page number)
if (!first) {//must be added, otherwise the Var URL will be refreshed indefinitely
= "{: U" (' Article/index ', Array (' page ' => ' Pageval ')} ";
var nowpage = E.curr; (clicked page number)
urls = urls.replace (' Pageval ', nowpage);//Replace link styles and page numbers
window.location.href = URLs;
}
});
JS Laypage (new version) Ajax paging
Function Demo (curr) {
$.getjson (' {: U (' Article/index ')} ', {
Page:curr//To server-side parameters, here is demo
}, function (res) {//The JSON results returned by the server//
This handles the content of the data in Res.lists, using the HTML () method to display
//slightly ...
Display Paging
laypage ({
cont: ' show_pages ',//Container
pages:res.allpage,// total pages (backstage)
Curr:res.nowpage,/ /Current page (background-acquired)
jump:function (obj, i) {//Trigger paging callback (after clicking Page number)
if (!first) {//Click the Jump page to trigger the function itself, and pass the current page: Obj.curr
demo (Obj.curr);//(Clicked page number)}
}
)
;}; Initialize run
demo ();
The above is the entire content of this article, I hope to learn more about the page component Laypage Help.