I got a blog-like webapp, and when user click like on post it does this function:
@main.route('/like/<int:post_id>/<action>')
@login_required
def like_action(post_id, action):
post = Post.query.filter_by(id=post_id).first_or_404()
if action == 'like':
current_user.like_post(post)
db.session.commit()
if action == 'unlike':
current_user.unlike_post(post)
db.session.commit()
return redirect(request.referrer)
It likes the post but it refresh the webpage so it scrolls all the way up and the post is scrolled down. Is there any way to make it work? so it will show the like but not refresh whole page ?
Aucun commentaire:
Enregistrer un commentaire