This is part of a the series to build a LiveView site for my podcast. At the end of last episode, I challenged listeners to come up with a way to redirect users who comment on an episode page back to the place where they commented instead of to an index of all comments.
It's essentially the same functionality that's implemented right here on Alchemist Camp.
The challenge
After users write or edit a comment on a page on our site, we want the "back" button to take the page they commented on instead of a listing of all comments. We also want to redirect them to the specific part of the page where the comment is, using a URL fragment (also known as an HTML anchor).
My solutions
In this video I do a walk-through of two different ways to do it. The first will make the "back" link on comment "show" pages link to either a comment listing page or the episode page where the user wrote their comment, depending on which page they came from. The second way will always send the user to the page where they wrote the comment, but it's far simpler to implement!
(Source code available for premium members)
No Comments