Live View Store Data in URL Params: Revision history

Jump to: navigation, search

Diff selection: Mark the radio buttons of the revisions to compare and hit enter or the button at the bottom.
Legend: (cur) = difference with latest revision, (prev) = difference with preceding revision, m = minor edit.

16 April 2025

  • curprev 15:2415:24, 16 April 2025Admin talk contribs 884 bytes +884 Created page with "<source> defmodule AppWeb.PageLive do use AppWeb, :live_view def mount(_params, _session, socket) do {:ok, socket} end def handle_params(params, _uri, socket) do count = String.to_integer(params["count"] || "0") {:noreply, assign(socket, count: count)} end def handle_event("increment", _, socket) do new_count = socket.assigns.count + 1 # Use ~p instead of Routes {:noreply, push_patch(socket, to: ~p"/?count=#{new_count}")} end d..."