【问题标题】:Error implement pagination with Meteor-Pages使用 Meteor-Pages 实现分页时出错
【发布时间】:2014-05-10 00:43:49
【问题描述】:

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

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

流星页面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>

【问题讨论】:

    标签: javascript pagination meteor


    【解决方案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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-19
      • 2014-12-20
      • 1970-01-01
      • 2018-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多