mharris717 / ember-cli-pagination

Pagination Addon for Ember CLI
MIT License
272 stars 116 forks source link

[Infinite scroll] How to disable load more action on last page #95

Open davidpaulsson opened 9 years ago

davidpaulsson commented 9 years ago

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
ryanlntn commented 9 years ago

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.

mharris717 commented 9 years ago

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

michaeldeitcher commented 9 years ago

This solution worked for me with pagedContent: pagedArray('content', { infinite: true })

  showLoadMore: Ember.computed('content.totalPages', 'content.page', ->
    @get('content.totalPages') > @get('content.page')
  )