So I’m having trouble trying to do a simple redirect from a LiveView event handler, and I’m not sure where my difficulty lies…
Firstly, is it possible to live_redirect
to an entirely different LiveView? (This code is in CreateBoardLive.) I suppose this should be preferable, but it didn’t seem to work, nor did I get any error message.
{:noreply, live_redirect(socket, to: Routes.live_path(socket, BoardLive, id))}
Then, I followed another example which seemingly should do a regular redirect.
{:stop, redirect(socket, to: Routes.live_path(socket, BoardLive, id))}
In both cases, I can see my tuple is returning from handle_event/3
, but nothing seems to happen on the web page – I’m still just looking at the form. No errors or interesting feedback is given in the browser or backend consoles.
For context, the code in question is here: https://github.com/djthread/lucidboard/blob/create-board-liveview/lib/lucidboard_web/live/create_board_live.ex#L70
Much thanks for any clarity on this!
Cheers.