소스 검색

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}}
     {{/each}}
     {{#if nextPath}}
     {{#if nextPath}}
       <a class="load-more" href="{{nextPath}}">Load more</a>
       <a class="load-more" href="{{nextPath}}">Load more</a>
+    {{else}}
+      {{#unless ready}}
+        {{> spinner}}
+      {{/unless}}
     {{/if}}
     {{/if}}
   </div>
   </div>
 </template>
 </template>

+ 3 - 2
lib/router.js

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