Переглянути джерело

Commit 12-5: Add a spinner to make pagination nicer.

Frederic G. MARAND 9 роки тому
батько
коміт
6a36630b33
2 змінених файлів з 7 додано та 2 видалено
  1. 4 0
      client/templates/posts/posts_list.html
  2. 3 2
      lib/router.js

+ 4 - 0
client/templates/posts/posts_list.html

@@ -5,6 +5,10 @@
     {{/each}}
     {{#if nextPath}}
       <a class="load-more" href="{{nextPath}}">Load more</a>
+    {{else}}
+      {{#unless ready}}
+        {{> spinner}}
+      {{/unless}}
     {{/if}}
   </div>
 </template>

+ 3 - 2
lib/router.js

@@ -21,8 +21,8 @@ PostsListController = RouteController.extend({
       limit: this.postsLimit()
     };
   },
-  waitOn: function () {
-    return Meteor.subscribe('posts', this.findOptions());
+  subscriptions: function () {
+    this.postSub = Meteor.subscribe('posts', this.findOptions());
   },
   posts: function () {
     return Posts.find({}, this.findOptions());
@@ -34,6 +34,7 @@ PostsListController = RouteController.extend({
     });
     return {
       posts: this.posts(),
+      ready: this.postSub.ready,
       nextPath: hasMore ? nextPath : null
     };
   }