js多功能分頁組件layPage使用方法詳解,jslaypage

來源:互聯網
上載者:User

js多功能分頁組件layPage使用方法詳解,jslaypage

本文的主要目的就是為大家分享layPage 多功能的js分頁組件具體操作方法,供大家參考,具體內容如下

php 部分

function index(){  header('Content-Type:text/html;charset=utf-8');  // 擷取當前頁碼,預設第一頁,設定每頁預設顯示條數  $nowpage = I('get.page', 1, 'intval');  $limits = 8;  // 擷取總條數  $count = M('Article') -> where(array('status'=>array('egt', 0))) -> count();  // 計算總頁面  $allpage = ceil($count / $limits);  $allpage = intval($allpage);      $lists = M('Article') -> where(array('status'=>array('egt', 0)))          -> page($nowpage, $limits) // page 方法分頁          -> order('createtime desc')          -> select();    // 跳轉分頁輸出  $this -> assign('lists', $lists);  $this -> assign('allpage', $allpage);  $this -> assign('nowpage', $nowpage);  $this->display();    /*  // ajax 分頁輸出  $info = array('lists'=>$lists,'allpage'=>$allpage,'nowpage'=>$nowpage);  $this->ajaxReturn($info,'json');  */   }

js 中 laypage(新版本) 跳轉分頁

// 分頁laypage({  cont: 'show_pages', // 分頁容器  pages: "{$allpage}",   // 總頁數  skip: true, //是否開啟跳頁  curr: function(){    var page = "{$nowpage}"; // 當前頁(後台擷取到的)    return page ? page : 1; // 返回當前頁碼值  }(),  jump: function(e, first){ //觸發分頁後的回調(單擊頁碼後)    if(!first){ //一定要加此判斷,否則初始時會無限重新整理      var urls = "{:U('article/index',array('page'=>'pageval'))}";      var nowpage = e.curr; // (被單擊的頁碼)      urls = urls.replace('pageval',nowpage); // 替換連結樣式和頁碼      window.location.href = urls;    }  } });

js 中 laypage(新版本) ajax 分頁

function demo(curr){  $.getJSON("{:U('article/index')}", {    page: curr //向服務端傳的參數,此處只是示範  }, function(res){ // 伺服器返回的 json 結果    // 這裡處理 res.lists 中的資料內容,使用 html() 方法顯示    // 略……        //顯示分頁    laypage({      cont: 'show_pages', // 容器      pages: res.allpage,   // 總頁數(背景)      curr: res.nowpage, //當前頁(後台擷取到的)      jump: function(obj, first){ //觸發分頁後的回調(單擊頁碼後)        if(!first){ //點擊跳頁觸發函數自身,並傳遞當前頁:obj.curr          demo(obj.curr); // (被單擊的頁碼)        }      }    });  }); }; // 初始化運行demo();

以上就是本文的全部內容,希望對大家學習分頁組件layPage有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.