D4no0

D4no0

Using liveview as root layout

Hello,
currently I have an application that uses liveview mostly. At the current moment I have popup menu with some other buttons that are handled in javascript. I wanted to refactor and change all the javascript with a liveview component.

The way I decided to move everything from app to a new liveview, and leave the app only as reference to liveview layout:
app.html.eex |> root_layout.html.leex |> other children layouts

Is there any downside to this approach? Or is it possible to refactor root layout to be liveview directly?

Most Liked

paulgoetze

paulgoetze

Hey, I’d would probably set up a root.html.eex, app.htlm.eex, and live.html.leex, as it was done in the live_view example app: Fix layouts · chrismccord/phoenix_live_view_example@c683680 · GitHub . This works for phoenix_live_view v0.10.0.

This allows you to have both routes with and without LiveView (e.g. if you just need a static page at some point or the like.)

Last Post!

D4no0

D4no0

This is what I currently have, this solves none of the problems. What I will end up doing most probably is to put multiple liveviews in root and allow communication between them via pubsub.

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Other popular topics Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44167 214
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement