Code Monkey home page Code Monkey logo

js-pagehelper's Introduction

js-pagehelper

js-pagehelper 是一个javascript的分页插件,用户listview这种形式的加载数据,支持上拉加载数据
有待优化!
有bug请提issues,感谢


使用例子: 先引入jQuery 或者 Zepto 然后引入pagehelper.js

列表加载方式一:
进入页面就开始加载数据:

var data = getParams(); 
$.pagehelper({ 
  obj : $('.list-box > ul'), 
  url : "/user/userlist", 
  params : data, 
  buildHtml : buildHtml 
}).startPage(); 

function getParams() { 
  // ...... 获取请求需要的参数 
}

function buildHtml(json) {
  var resultHtml = ''; 
  // ...... 生成所需要的html 
  return resultHtml; 
} 

列表加载方式二:
进入页面有第一页的数据:
var data = getParams(); 
$.pagehelper({ 
  obj : $('.list-box > ul'), 
  url : "/user/userlist", 
  params : data, 
  buildHtml : buildHtml 
}).setPage(1, 100);

setPage(pageNum, pages)是设置pageNum 和 pages pageNum的意思是当前页数,pages的意思是总页数

列表加载方式三:
有搜索条件时,点击搜索确定时调用:
var data = getParams(); 
$.pagehelper({ 
  obj : $('.list-box > ul'), 
  url : "/user/userlist", 
  params : data, 
  buildHtml : buildHtml 
}).resetPage();


PS:服务器返回的数据内容:
{
  // 其他属性...
  'body':{
    'pageNum':1, // 当前页数
    'pages':100, // 总页数
    'list':[] // 内容对象集合
    // 其他属性...
  }
}

js-pagehelper's People

Contributors

xxzkid avatar

Stargazers

Sogrey avatar

Watchers

James Cloos avatar  avatar

Forkers

michealjou

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.