← All series

Series contents

Log in to track your progress

  1. 1. Simple Phoenix LiveView App: Setup Episode
  2. 2. Simple Phoenix LiveView App: Planning DB Schemas Episode
  3. 3. Simple Phoenix LiveView App: Upgrade to LiveView 0.5.1 Episode
  4. 4. Simple Phoenix LiveView App: Socket Session info, CSRF & .leex Episode
  5. 5. Simple Phoenix LiveView App: Scaffolding Users & Content Episode
  6. 6. Simple Phoenix LiveView App: PubSub & Index Episode
  7. 7. Simple Phoenix LIveView App: Show & Edit Pages Episode
  8. 8. Simple Phoenix LiveView App: Upgrade LiveView to v0.8.1 Episode
  9. 9. Simple Phoenix LiveView App: Fonts, logos and sass Episode
  10. 10. Simple Phoenix LiveView App: Markdown show notes Episode
  11. 11. Simple Phoenix LiveView App: The Podcast Listing Page Episode
  12. 12. Simple Phoenix LiveView App: Upgrade LiveView to v0.12.1 Episode
  13. 13. How I add auth to Phoenix LiveView apps Episode
  14. 14. Simple Phoenix LiveView App: planning comments Episode
  15. 15. Showing comment counts on the index page (Simple Phoenix LiveView App) Episode
  16. 16. Simple Phoenix LiveView app: Embedded comments form Episode
  17. 17. Passing redirect URLs + fragments Episode
  18. 18. Simple Phoenix LiveView App: Series Complete! Episode

Passing redirect URLs + fragments

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)

Open standalone page ↗

No Comments