4 ms·
It's unfortunate there's no standard way to dispatch this kind of thing ARIA wise. Fortunately live navigation is opt-in, so folks can continue to use `<%= link
by chrismccord 5y ago
It's unfortunate there's no standard way to dispatch this kind of thing ARIA wise. Fortunately live navigation is opt-in, so folks can continue to use `<%= link "page", to: ... %>` vs `<%= live_redirect "page", to: %>` when needed. On the form submission side, we actually still have you covered within LiveView, because the server can instruct the client to do a plain redirect:
def handle_event(save, params, socket) do
...
{:noreply,
socket}
|> put_flash(:info, "It worked!"
|> redirect(to: "..."))}
end
So the server can do `redirect` or `live_redirect` and flash works in both cases, so I believe this broadens LiveView usage a bit for your data entry requirements.
I'll also check out the ARIA region approaches. I think something like that would be drop-in for LiveView in the live layout, and we at the very least could include docs on it.
- iudqnolq 5y agoAs far as I know you can't pipe that sort of tuple through those functions. Is that a future feature? It would be mildly convenient if assign({:noreply, socket}), ...) == {:noreply, assign(socket, ...)}
- wut42 5y agoThere is a misplaced `}` :) He actually wanted to do : def handle_event(save, params, socket) do ... {:noreply, socket |> put_flash(:info, "It worked!" |> redirect(to: "..."))} end which would work.
- iudqnolq 5y agoAh. It's a nonstandard formatting though.
- wut42 5y agoAgree-- Even if it's possible I always feel dirty to do that kind of "magic", and always prefer this way: def handle_event(save, params, socket) do socket = socket |> put_flash(:info, "It worked!") |> redirect(to: "...") {:noreply, socket} end I feel like it's more readable this way.