Search code examples
javascripthtmldjangodjango-comments

How to stay at the same place of the page after you send post comment using Django-comments


Now I use next code <input type="hidden" name="next" value="{{ request.get_full_path }}" /> in comments/form.html and after I post a new comment the page with content and comments list refreshes and I should scroll down to see my post. It's not what I exactly want.

I want to stay at the same page after send a post, without refreshing. It's possible?


Solution

  • There are two principle ways of doing what you want:

    1. Give a unique id for each comment and pass it to the url to create a so-called bookmark. You'll get smth like http://the/url/you/want#desired-post-id and so you will automatically jump to the post you want.
    2. Use ajax to refresh only a part of a page that you are really changing. In that case you'll just stay there you are.