User contributions for Admin

Jump to: navigation, search
Search for contributionsExpandCollapse
⧼contribs-top⧽
⧼contribs-date⧽
(newest | oldest) View (newer 50 | ) (20 | 50 | 100 | 250 | 500)

10 May 2025

  • 07:0007:00, 10 May 2025 diff hist +720 N LiveView Web API Request ExampleCreated page with "<source> defmodule AppWeb.Sandbox do use AppWeb, :live_view def mount(_params, _session, socket) do {:ok, socket} end def handle_event("start_task", _params, socket) do Task.async(fn -> Req.get!("https://api.github.com/repos/wojtekmach/req") end) {:noreply, socket} end def handle_info({ref, result}, socket) do Process.demonitor(ref, [:flush]) IO.inspect"________________________________________________________________________________"..." current
  • 05:1505:15, 10 May 2025 diff hist +793 N Phoenix Handle Info Self ExampleCreated page with "<source> defmodule AppWeb.Sandbox do use AppWeb, :live_view require Logger def mount(_params, _session, socket) do {:ok, assign(socket, :count, 0)} end def handle_event("increment", _params, socket) do # Send a message to ourselves after 1000 milliseconds (1 second) Process.send_after(self(), :delayed_increment, 1000) {:noreply, socket} end def handle_info(:delayed_increment, socket) do new_count = socket.assigns.count + 1 Logger...." current

17 April 2025

  • 20:1720:17, 17 April 2025 diff hist +24 Sort Collection Via Event HandlerNo edit summary current
  • 19:5519:55, 17 April 2025 diff hist +1,388 N Sort Collection Via Event HandlerCreated page with "<source> defmodule AppWeb.SandboxLive do use AppWeb, :live_view alias App.TestBeds alias App.TestBeds.TestBed alias App.Repo import Ecto.Query def mount(_params, _session, socket) do testbeds = Repo.all(from(t in TestBed, order_by: t.name)) {:ok, assign(socket, testbeds: testbeds, sort_by: :name, sort_direction: :asc)} end def handle_event("toggle_sort_by_name", _params, socket) do current_direction = socket.assigns.sort_direction new_..."

16 April 2025

  • 15:2415:24, 16 April 2025 diff hist +884 N Live View Store Data in URL ParamsCreated 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..." current

8 April 2025

2 April 2025

23 March 2025

22 March 2025

19 March 2025

13 March 2025

12 March 2025

11 March 2025

20 February 2025

29 December 2024

27 December 2024

  • 09:2109:21, 27 December 2024 diff hist +419 N How to Think About Phoenix Dead ViewsCreated page with "Each page (resource) has a route. These routes are assigned a controller and a function from that controller. In the code below, when a user goes to the "/" route a controller named PageController is found and a function named home is invoked. Controllers are simply modules and the third argument (in this case named '''home''') is a function on the controller. <source> get "/", PageController, :home </source>" current
  • 09:1209:12, 27 December 2024 diff hist +39 Phoenix Flash MessageNo edit summary current
  • 09:1209:12, 27 December 2024 diff hist +8 Phoenix Flash MessageNo edit summary
  • 09:1109:11, 27 December 2024 diff hist +625 N Phoenix Flash MessageCreated page with "In Phoenix the flash message is invoked from the controller. <source> def create(conn, %{"doink" => doink_params}) do case Doinks.create_doink(doink_params) do {:ok, doink} -> conn |> put_flash(:info, "Doink created successfully.") |> redirect(to: ~p"/doinks/#{doink}") {:error, %Ecto.Changeset{} = changeset} -> render(conn, :new, changeset: changeset) end end </source> The message itself needs to be in the view..."

24 December 2024

23 December 2024

8 December 2024

29 November 2024

25 November 2024

24 November 2024

11 October 2024

10 October 2024

21 August 2024

17 August 2024

16 August 2024

(newest | oldest) View (newer 50 | ) (20 | 50 | 100 | 250 | 500)