Search code examples
javascriptruby-on-railsruby-on-rails-4will-paginateturbolinks

Rails4: How can I change a display position after clicking a link?


I use will_paginate at the bottom of the page.
Although the page is displayed after clicking the page number, the position of a scroll remains the same (bottom of the page).
I'd like to display the top of the page.

How can I change the display position?

\view\calendars\index.html.erb

...
<%= will_paginate @calendar %>
...

Solution

  • You can use javascript for this

    $("html, body").animate({ scrollTop: 0 }, "slow");