Navigation
April 22, 2022 1 minutes • 73 words
Table of contents
Liveview has two ways to Navigate:
- Client
# 0.16
<%= live_patch "Text", to: Routes.live_path(@socket, __CURRENTMODULE__, id: struct.id) %>
# 0.19
<.link patch={~p"/pages/#{@page}"}Go</.link>
- Server
# 0.16
push_patch(to: socket.assigns.return_to)
# 0.19
{:noreply, push_patch(socket, to: ~p"/pages/#{@page})
live_patch push_patch
This navigates to the same Liveview.
Live Routes are PATCH
because it updates or patches the LiveView process with the new data and sends a new ‘diff’ to the DOM
__CURRENTMODULE__
is a shortcut for the Module Name