Skip to content

Commit

Permalink
Add a spinner to make pagination nicer
Browse files Browse the repository at this point in the history
chapter12-5
  • Loading branch information
tmeasday committed Oct 19, 2015
1 parent 6ff286c commit 55a5168
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions client/templates/posts/posts_list.html
Expand Up @@ -6,6 +6,10 @@

{{#if nextPath}}
<a class="load-more" href="{{nextPath}}">Load more</a>
{{else}}
{{#unless ready}}
{{> spinner}}
{{/unless}}
{{/if}}
</div>
</template>
5 changes: 3 additions & 2 deletions lib/router.js
Expand Up @@ -16,8 +16,8 @@ PostsListController = RouteController.extend({
findOptions: function() {
return {sort: {submitted: -1}, limit: this.postsLimit()};
},
waitOn: function() {
return Meteor.subscribe('posts', this.findOptions());
subscriptions: function() {
this.postsSub = Meteor.subscribe('posts', this.findOptions());
},
posts: function() {
return Posts.find({}, this.findOptions());
Expand All @@ -27,6 +27,7 @@ PostsListController = RouteController.extend({
var nextPath = this.route.path({postsLimit: this.postsLimit() + this.increment});
return {
posts: this.posts(),
ready: this.postsSub.ready,
nextPath: hasMore ? nextPath : null
};
}
Expand Down

0 comments on commit 55a5168

Please sign in to comment.