Meteor pagination using meteor-pages not working


#1

Hello Meteorites, I’ve tried posting this question on Stack Overflow but I’ve got no answer so fare, so I’m bringing this to your attention hoping you can help me here (I’m getting started with Meteor)

The issue is with meteor-pages package.

I am setting up meteor-pages like so

Snippets = new Mongo.Collection('snippets');

this.Pages = new Meteor.Pagination("Snippets", {
  perPage: 3
});

Pages.set({
  perPage: 3,
  sort: {
    title: -1
  }
});

in my router

Router.configure({
  layoutTemplate: 'layout',
  loadingTemplate: 'loading',
  waitOn: function(){
    return Meteor.subscribe('snippets');
  }
});

in my templates

<template name="snippets">
   {{>snippetsList}}
   {{> pages}}
   {{> pagesNav}}
</template>

<template name="snippetsList">
  <div>
    {{#each snippet}}
      <div>
        <p>{{text}}</p>
        <a href="{{pathFor 'snippetEdit'}}" class="btn btn-default btn-sm edit">Edit</a>
        <button type="button" class="btn btn-default btn-sm btn-danger delete">Delete</button>
      </div>
    {{/each}}
  </div>
</template>

What do you think? What’s wrong? Many thanks!


#2

What is wrong?

What aren’t you seeing that you are expecting to see?


#3

Ah, right :slight_smile:

I’m not seeing anything at all


#4

Hello. Did you solve your issue? Say how. Because I don’t understand how to use this package.


#5

this.Pages = new Meteor.Pagination(Snippets, {
perPage: 3
});

The parameter is not the Snippets name , we should use the Sinppets variable
The Snippets must be a collection not subs


#6

Cannot say with 100% confident, but maybe package is not required for paging, because it’s quite easy to use “skip and limit” for published data. Variables that can been seen on both client and server can be used to set conditions for the data. Not 100% sure, but atleast I have used skip and limit (paging) at client-side already, and I do not see why “a global variable” could not be used to provide conditioning between server pub and client sub.