【问题标题】:How to stay at the same place of the page after you send post comment using Django-comments使用 Django-comments 发送评论后如何留在页面的同一位置
【发布时间】:2016-06-11 17:34:36
【问题描述】:

现在我在 cmets/form.html 中使用下一个代码 <input type="hidden" name="next" value="{{ request.get_full_path }}" />,在我发布新评论后,包含内容和 cmets 列表的页面会刷新,我应该向下滚动以查看我的帖子。这不是我真正想要的。

我想在发送帖子后停留在同一页面,而不刷新。有可能吗?

【问题讨论】:

标签: javascript html django django-comments


【解决方案1】:

有两种基本方法可以做你想做的事:

  1. 为每条评论指定一个唯一的id 并将其传递到 url 以创建所谓的书签。你会得到像http://the/url/you/want#desired-post-id 这样的东西,所以你会自动跳转到你想要的帖子。
  2. 使用ajax 仅刷新您真正更改的页面的一部分。在这种情况下,你就一直呆在那里。

【讨论】:

    猜你喜欢
    • 2013-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-26
    • 2018-09-12
    • 2013-08-28
    • 2015-06-12
    • 1970-01-01
    相关资源
    最近更新 更多