Code Monkey home page Code Monkey logo

Comments (3)

superRaytin avatar superRaytin commented on May 24, 2024
  1. 异步分页时,totalNumber 是必须指定的,可以在第一次请求获取到 totalNumber,再实例化分页。
  2. 是个 Bug,已修复。

PS: 改为 one 的方式不可取,因为 one 始终只会触发一次,会造成无法再次触发事件。所以修复方案就是初始化新实例之前卸载旧的。

最后谢谢将 Bug 提出来!

from paginationjs.

webeautiful avatar webeautiful commented on May 24, 2024

追问第一个问题:
我的需求正如你所说,在通过dataSource: url形式第一次进行异步请求,拿到第一页数据的同时也拿到了totalNumber,但是不知道该如何在实例化分页导航条前,把从异步请求获取的总页数设置为totalNumber,你的demo中只体现了请求前设置好totalNumber, 而没有体现请求数据到达后,如何将拿到的数据设置为totalNumber。还请赐教,不甚感激!

最后,谢谢你写了这么nice的开源库!:thumbsup::thumbsup::thumbsup::thumbsup::thumbsup:

from paginationjs.

superRaytin avatar superRaytin commented on May 24, 2024

Hmm...你说的这种用法有点像 #2 提到的,目前异步分页模式必须一开始指定 totalNumber,不然无法完成初始化

Pagination.js 是根据总记录数(totalNumber)和每页条数(pageSize)来产出分页形态,分页类组件都是此机制的哦,所以数据总条数变了,总页数也就变了,分页实例必须要重新生成 ...

提供一个简单的示例,看是否对你有帮助:

$.get('/data.json', function(response) {
    var totalNumber = response.totalNumber;
    $('#demo').pagination({
        dataSource: '/data.json',
        totalNumber: totalNumber,
        callback: function(data, pagination){
            // template method of yourself
            var html = template(data);
            dataContainer.html(html);
        }
    });
});

from paginationjs.

Related Issues (20)

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.