错误实现Meteor-Pages的分页

时间:2014-05-09 04:35:43

标签: javascript pagination meteor

我指的是Meteor-Pages的基本演示。

基本演示https://github.com/ianpogi5/meteor-pages/tree/master/examples/basic

Meteor-pages https://atmospherejs.com/package/pages

我们的想法是创建分页并在每个页面上显示1条推荐。

浏览器上没有显示任何内容,我遇到了这些错误:

Uncaught TypeError: Cannot set property 'pagesData' of undefined 

Exception from Deps recompute function: Error: Expected null or template in return value     
from inclusion function, found: [object Object]

我的代码是:

pages.coffee

@Pages = new Meteor.Pagination 'Recommendations',
  perPage: 1

recommendations.coffee

@Recommendations = new Meteor.Collection("recommendations")

recommendations_list.html

<template name="recommendationsList">
 <h1>Recommendations for each user</h1>
  <div>
   {{#each recommendations}}
    {{> recommendationItem}}
   {{/each}}
  </div>

  {{> recommendations}}
</template>

<template name="recommendations">
 {{> pagesNav}}
 {{> pages}}
</template>

1 个答案:

答案 0 :(得分:1)

解决了,我之前的代码有两件事我做错了。以下是修改后的内容。

recommendations.coffee

@Recommendations = new Meteor.Collection("recommendations")

// Pagination must put directly under the collections, because we want to run the 
// collection first before making the pagination

@Pages = new Meteor.Pagination Recommendations,
  perPage: 1    

recommendations_list.html

<template name="recommendationsList">
 <h1>Recommendations for each user</h1>
  <div>
  {{> recommendations}}
  </div>
</template>

<template name="recommendations">
 {{> pagesNav}}
 {{> pages}}
</template>