0
votes

I am trying to use meteor-pages. In my JavaScript code I have:

Tasks = new Mongo.Collection("tasks");

Tasks.attachSchema(new SimpleSchema({
  title: {
    type: String,
    label: "Title",
    max: 200
  },
  complete: {
    type: Boolean,
      defaultValue: false,
    label: " ",
      autoform: {
          type: "boolean-checkbox"
      }
  },
  dueDate: {
    type: Date,
    label: "Due Date",
    optional: true,
      autoform: {
        type: "pickadate"
    }
  }
}));

Pages = new Meteor.Pagination(Tasks, {
  templateName: "tasksPaginated"
})

In my html, I have:

<template name="TaskList">
    Before
    {{> tasksPaginated}}
    After
</template>

    <template name="tasksPaginated">
        {{> pages}}
        {{> pagesNav}}  Bottom navigation
    </template>

When I try to browse to the page, I get the following error:

Exception in delivering result of invoking 'pages_tasks/CountPages': Error at Connection._livedata_result (http://localhost:3000/packages/ddp-client.js?hash=bc32a166cd269e06a394f9418e0024d805bab379:4736:23) at onMessage (http://localhost:3000/packages/ddp-client.js?hash=bc32a166cd269e06a394f9418e0024d805bab379:3385:12) at http://localhost:3000/packages/ddp-client.js?hash=bc32a166cd269e06a394f9418e0024d805bab379:2736:11 at Array.forEach (native) at Function..each..forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:149:11) at SockJS.self.socket.onmessage (http://localhost:3000/packages/ddp-client.js?hash=bc32a166cd269e06a394f9418e0024d805bab379:2735:11) at SockJS.REventTarget.dispatchEvent (http://localhost:3000/packages/ddp-client.js?hash=bc32a166cd269e06a394f9418e0024d805bab379:175:22) at SockJS._dispatchMessage (http://localhost:3000/packages/ddp-client.js?hash=bc32a166cd269e06a394f9418e0024d805bab379:1160:10) at SockJS._didMessage (http://localhost:3000/packages/ddp-client.js?hash=bc32a166cd269e06a394f9418e0024d805bab379:1218:18) at WebSocket.that.ws.onmessage (http://localhost:3000/packages/ddp-client.js?hash=bc32a166cd269e06a394f9418e0024d805bab379:1365:17)

Any ideas what I could be doing wrong?

2

2 Answers

0
votes

The documentation for meteor-pages says you can initialise it like this:

this.Pages = new Meteor.Pagination("tasks");

And this will automatically pick up a template called "tasks". The other way (which I think you want) is to specify a different template, in which case your code should be :

this.Pages = new Meteor.Pagination("tasks", {itemTemplate: "tasksPaginated"});

That should solve it for you

0
votes

Make sure the code

Pages = new Meteor.Pagination(Tasks, {
    templateName: "tasksPaginated"
})

don't run before your Template.tasksPaginated is available globally