ember-cli-pagination
ember-cli-pagination copied to clipboard
[Infinite scroll] How to disable load more action on last page
Hello, thanks for a great lib. I have a question I'm wondering if you have an idea how to implement.
I'm using the pagedContent: pagedArray('content', { infinite: true })
option, and when I'm at the bottom of the list, I show a button with the loadNext
action just as described in the docs
// Infinite scroll
loadNext: function() {
this.get('pagedContent').loadNextPage();
}
So far so good.
How would I spy on the currentPage
and the total_pages
properties from the returned meta object to disable/remove the "Load more" button when there are no more pages to load?
Any idea of how to implement this? Thank you!
I'm using
Ember: 1.10.0
Ember Data: 1.0.0-beta.15
ember-cli-pagination: 0.6.6
I'm curious about this as well.
I'm using pagedContent: pagedArray('filteredContent', { infinite: 'unpaged' })
in case that is any different.
I was able to implement this functionality like this:
showViewMore: Ember.computed('pagedContent.all.content.length', 'pagedContent.content.length', function() {
return this.get('pagedContent.all.content.length') > this.get('pagedContent.content.length');
}
It does seem like it should be easier/cleaner though.
Thanks for the issue, and @ryanlntn thanks for the reply!
I agree this should be easier, and probably built in. I will see what I can do
This solution worked for me with pagedContent: pagedArray('content', { infinite: true })
showLoadMore: Ember.computed('content.totalPages', 'content.page', ->
@get('content.totalPages') > @get('content.page')
)