【问题标题】:CakePHP Ajax Pagination - Scroll Top once new page clickedCakePHP Ajax 分页 - 单击新页面后滚动顶部
【发布时间】:2014-04-15 22:19:11
【问题描述】:

在 CakePHP 中使用 Ajax 分页时,它工作得很好,但如果页面要滚动到第一条记录,单击下一个或不同的页码时会很好。目前,页面重新加载,但继续停留在页面底部。有解决办法吗?

我看过这个: $("html, body").animate({ scrollTop: 0 }, "slow");

但我不确定如何在分页调用中实现这一点,例如:

$this->Paginator->options(array(
    'update' => '#content'
));

【问题讨论】:

    标签: ajax cakephp pagination


    【解决方案1】:

    您可以在“之前”和“完成”中为所有 Ajax 调用提供一些 Javascript,这些将在 Ajax 调用之前和完成 Ajax 调用时调用。

    $this->Paginator->options(array(
        'update' => '#content',
        'complete' => '$("html, body").animate({ scrollTop: 0 }, "slow");'
    ));
    

    【讨论】:

    • 很棒的东西——这正是我所追求的!非常感谢:)
    猜你喜欢
    • 2020-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多