synic
synic

Reputation: 26678

ember-cli-pagination - how to scroll to top of page on page change?

I've got the {{page-numbers}} at the bottom of the page. When I click a page number, the page loads fine, but I'm still at the bottom of the page.

How can I get it to scroll to the top when changing pages?

Is there a better addon to use for this?

Upvotes: 0

Views: 142

Answers (1)

synic
synic

Reputation: 26678

I was able to accomplish this by overriding the page-numbers component:

import PageNumberComponent from 'ember-cli-pagination/components/page-numbers';

export default PageNumberComponent.extend({
  actions: {
    pageClicked: function(number) {
      this._super(...arguments);
      window.scrollTo(0, 0);
    }
  }
});

Upvotes: 1

Related Questions