I have a live session
called :home
that consists of four LiveViews. From the LiveViews of this live session
the user can navigate to a set of ‘secondary’ pages (LiveViews and regular views). Whenever a user does so, this ‘secondary’ page should show a back button that returns the user to the LiveView that they navigated from. If the user loads a ‘secondary’ page directly from the browser’s location bar, the back button is still visible and returns the user to one of the :home
LiveViews by default.
I went into this problem thinking I would build it quickly, but cannot seem to find an elegant way to solve it. I can compare the navigation history (History API) with the URL’s of the :home
live session, but I wanted to try to store the URL of the LiveView before redirecting the user to the requested page. Because the user is redirected from a LiveView, rather than a regular view, I fail to see how I can add the URL to the session data of the redirected-to page. There is no redirect(socket, to: "/path", session: %{return_to: "/path"})
.
Edit:
So my question is: how can I pass data from a LiveView to a navigated-to LiveView/regular page?