欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery插件simplePagination的使用方法示例

 更新時間:2020年04月28日 11:12:19   作者:xiaoping  
這篇文章主要介紹了jQuery插件simplePagination的使用方法,結(jié)合實例形式分析了jQuery插件simplePagination實現(xiàn)表單分頁相關(guān)操作技巧與注意事項,需要的朋友可以參考下

本文實例講述了jQuery插件simplePagination的使用方法。分享給大家供大家參考,具體如下:

正在熟悉項目上的代碼,新添加了一個需要,需要對表單進(jìn)行分頁,之前的代碼中是有分頁的代碼的,看了老半天,也沒看太明白。之前的項目比較久遠(yuǎn),繼續(xù)熟悉代碼。

simplePagination的使用

HTML頁面,

<div class="row">
  <div class="col-sm-12 col-sm-12">
      <table class="table table-striped table-hover table-bordered" data-toggle="table" data-url="data2.json" data-pagination="true">
        <thead> 
          <tr>
            <th data-hide="phone" >可用區(qū)</th>
            <th data-hide="phone">渠道</th>
            <th data-hide="phone">引用可用區(qū)</th>
            <th data-hide="phone">引用渠道</th>
          </tr>
        </thead>
        <tbody id="region_price_list-data">
        
        </tbody>
      </table>
    </div>
  </div>
  
  <div class="row">
    <div class="col-sm-12">
      <div id="pagination">
      </div>
    </div>
  </div>

因為項目里用到EJS--HTML模板,記得在一開始就引用SimplePagination插件,這個比較簡單,就不細(xì)說了。

JS代碼

var page_count = 0;
// 定義分頁的頁數(shù)
var limit = 0 ;
// 定義分頁的條數(shù)
var regionLogListFunc = function(pageNumber){
  if(pageNumber=== undefined){
    pageNumber = 1;
  }
  // 頁數(shù)判斷和定義
  $get("/regionCopyList?page_number="+ pageNumber,function(data,status){  
    var #### = jQuery("####-##");
    // 獲取Table中 tbody的id值
    var updateRegionlogList = ''
     // for in 遍歷 對傳入的數(shù)據(jù)進(jìn)行顯示
    for (var i in data){
      #### +='<tr class= "odd gradeX">';
      ##### +='<td data-hide ="phone">'+data[i].##+'</td>';
      ##### +='<td data-hide ="phone">'+data[i].##'</td>';
      #### +='<td data-hide ="phone">'+data[i].##+'</td>';
      #### +='<td data-hide ="phone">'+data[i].##+'</td>';      
      updateRegionlogList +='</tr>';      
    } 
   regionPriceList.empty();
    //  添加更新的數(shù)據(jù)
   regionPriceList.append(updateRegionlogList);
  });
  var onPageClick = regionLogListFunc;
  // 獲取DOM文檔ID
  jQuery("#pagination").pagination({
    item    :<%=z###%>, //ejs模板
    itemsOnPage :<%=#####t%> ,//ejs模板
    cssStyle  :'light-theme',
    onPageClick :onPageClick,
    onInit   :regionLogListFunc,
  });
});

另外一種寫法是

var page_index;
var itemsOnPage = 1;
$(function() {
$("#pagination").pagination({
  items: {$page_count}, 總頁數(shù)
  itemsOnPage: itemsOnPage,
  cssStyle: 'light-theme',
  onInit: changePage,  // 初始化函數(shù)
  onPageClick: changePage  //點(diǎn)擊時觸發(fā)函數(shù)
  }); 
}); 
function changePage(page_index,event){ 
  listTable.gotoPage(page_index);  //gotoPage函數(shù)調(diào)用ajax獲取數(shù)據(jù) 填充頁面
  document.getElementById('pageCurrent').innerHTML=page_index; 
  return true; 
}

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery切換特效與技巧總結(jié)》、《jQuery遍歷算法與技巧總結(jié)》、《jQuery常見經(jīng)典特效匯總》、《jQuery動畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對大家jQuery程序設(shè)計有所幫助。

相關(guān)文章

最新評論