Meteor Pagination. Made Easy! No Meteor Packages!

using the plugin at http://paginationjs.com/

Note you’ll need a data source for this whole process to work. here mine ;
var allUsers = Meteor.users.find().fetch();

function toSingleUser(allUsers) {
    $.each(data, function (index, item) {
        html += Blaze.toHTMLWithData(Template.userBox, item) //
    });
  
    return html 
}

$('#whereyouwanto').pagination({
    dataSource:  Meteor.myusers.find().fetch() ;// or allUserx 
    , callback: function (data, pagination) {
        var html = toSingleUser(data)
        $('#anything').html(html);
    }
})

This by definition uses a “package”, it even goes so far to use a not-recommended way of including jQuery plugins…

4 Likes

Well It works. So How do you paginate?

It’s confusing that you’re saying

and then suggest paginationjs, which is clearly a package, and even depends on jQuery :confused:

You should take a look at some of the patterns for pagination that relies on Meteor’s subscriptions and publications, which’ll not only help you paginate/infinite scroll, but also reduce the amount of data loaded into minimongo on the client. here’s an example :sunny:

2 Likes

Yeah I’m pretty sure the whole point of pagination is to avoid sending too much data to the client. If you have 100,000 records on the server and want to load/display just 10 at a time, a jquery plugin can’t help you there.

7 Likes

Will test that and reply

This is only client side pagination. I think you can do pagination without any packages at all.

1 Like

So after two years I understood when I finally got to work , and noticed Apis with page and page size queries :joy::sob: