According to some people in the Elixir slack, the phx-value- prefix should be used to pass the value along, so, this is what I have now,
The button looks like this:
<button type="button" class="rv-Button--tiny" :on-click="show_driver_availability_info" phx-value-show_driver_avail_info={{ @show_driver_avail_info? }}>See Driver Availability Info</button>
Here’s the event_handler:
def handle_event(
"show_driver_availability_info",
%{"show_driver_avail_info" => show_driver_avail_info?},
socket
) do
IO.puts("show_driver_availability_info being called")
socket = assign(socket, :show_driver_avail_info?, true)
{:noreply, socket}
end
And when the button is clicked, this is the error I’m getting:
(FunctionClauseError) no function clause matching in TSSWeb.DispatchHomeLive.handle_event/3
(tss 0.0.1) lib/tss_web/live/dispatch_home_live/dispatch_home_live.ex:406: TSSWeb.DispatchHomeLive.handle_event("show_driver_availability_info", %{"value" => ""}, #Phoenix.LiveView.Socket<assigns: %{__context__: %{}, __surface__: %{}, breadcrumb_trail: [[name: "Home", url: "/"], [name: "Wells", url: "/wells_board"], [name: "Dispatch Board - Argent Barksdale East 29-17 4LS/4WA/6LS/6WA/7LS/7WA", ...]], connected?: true, current_user: %TSS.User{last_signed_in_at: ~U[2021-02-22 15:45:09.535722Z], password: "$2b$12$deK4g0VNl2lJPNKlTRfoSeapIceDCWb/axPDlexmTV.iNvQL/jXDS", ...}, flash: %{}, forecast_data: %{...}, ...}, changed: %{}, endpoint: TSSWeb.Endpoint, id: "phx-Fn21s0dRpOhSdzwh", parent_pid: nil, root_pid: #PID<0.6038.0>, router: TSSWeb.Router, view: TSSWeb.DispatchHomeLive, ...>)
The “value” is still empty, am I passing it along correctly?


















