I'm using Nodejs. First time posting here. Short story, I write a comment in a form. It is submitted it as a POST request. My server processes it. Then it res.redirect(req.get('referer')), aka reloads my page and puts me at the top with my comment posted. Everything works except for keeping my scroll position. I'm using the Handlebars engine which makes adding javascipt tricky. Looking at other threads, none of the proposed solutions work for me. This excerpt of coding shows only the form submitting, and the server responding.
<body>
...
<form id="leavecomment" form method="post" action="/form3/comment/{{video._id}}">
<div class="form-group">
<textarea input type="text" class="form-control" name="new_comment"></textarea>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</body>
on the server:
router.post('/comment/:id', ensureAuthenticated, function(req, res){
...
Form.update(query, form, function(err){
if(err){
console.log(err);
return;
} else {
res.redirect(req.get('referer'));
return;
}
});
}
Once again, everything works except being able to keep my scroll position. I'm wondering if I can get my page to detect a return
I have tried a variety of methods including everything posted on these two threads:MaintainScrollPositionOnPostback property doesn't works with mozilla and Retain scrollbar position even after reloading using javascript Thanks for your help.