scrollTop
doesn't work every other click (every second click).
I use will_paginate
at the bottom of the page.
When I click on a link, the page is refreshed and the display position is at the bottom of the page.
Then I click on a link to another page, the page is refreshed and the display position is at the top of the page as I expect.
For example,
When I click the link to page 2, the page 2 is displayed but the display position remains at the bottom.
When I click the link to page 5, the page 5 is displayed and the display position is at the top as I expect.
When I click the link to page 6, the page 6 is displayed but the display position remains at the bottom.
When I click the link to page 8, the page 8 is displayed and the display position is at the top as I expect.
...
I have tried the followings, I had the same result.
\assets\javascripts\calendars.js.coffee
$('html, body').animate({ scrollTop: 0 }, 'slow')
$('body').animate({ scrollTop: 0 }, 'slow')
$('html, body').scrollTop()
$(document).scrollTop()
$(window).scrollTop()
$(window).scrollTop(0)
\views\calendars\index.html.erb
...
<%= will_paginate @calendar %>
...
How should I edit my code?