假设我有几个长页面,并且我想使用 pjax。当我将一页滚动到末尾,然后单击调用 pjax 重新加载的链接时,第二页的视口将从页面末尾开始(如果没有 pjax,浏览器将从页面顶部开始)。
我看到的另一个缺点是,当单击后退按钮时,前一页的视口将再次保留,并且不会返回到前一页上的状态。
这种行为很烦人而且不可用。是否可以使用 pjax 模拟标准浏览器的行为?
Let assume I've got few long pages, and I want to use pjax. When I scroll one page to the end, then click a link invoking pjax reload, then the second page's viewport starts at the end of page (while without pjax the browser would start on the top of page).
Other drawback I see is that when clicking back button the previous page's viewport is again preserved, and not returned back to what it was on the previous page.
This behavior is annoying and not usable. Is it possible to simulate the standard browser's behavior with pjax?
发布评论
评论(1)
我的解决方案是绑定到 pjax:end 事件并将页面滚动到顶部;唯一的小缺点是后退按钮仍然不记得滚动位置,并且总是从顶部开始。
My solution to this is to bind to the
pjax:end
event and just scroll the page to the top; the only slight downside is that the back button still doesn't remember the scroll position and will always start at the top.