LOG67

LOG67

Embed Eex or Leex Inside Parent Leex Without Spawning a New Process

I am writing an app with many pages using the same format of a table with filtering, sorting, and pagination. I want to extract the shared logic for rendering and event handling of these pages and put it into a separate component, I also need to live redirect based on filtering and sorting. At the moment using Macros I can define callbacks to get the table data from the parent page and inject the required function definitions for handling the sort and filter events. But for render, I don’t know what is the best approach to include my view for the table (which includes click event definitions) in the parent’s render function.

p. s. I am aware I can use nested stateful liveviews and use something like Registery to communicate between parent and child processes and handle redirects like that. To me, it seems too much ceremony and indirection for a simple task and I do not want to take that route if possible.

Marked As Solved

OvermindDL1

OvermindDL1

Welcome around!

Instead of embed, why not just define the other eex/leex and just render it in yours, or via a global one. No need to create a new process or anything for another render? I’m not really understanding what you are doing to be honest though. ^.^;

Also Liked

LOG67

LOG67

Thanks!

You are right, for some reason I was not thinking straight! I just rendered the eex template inside the liveview and it is working as expected.

1player

1player

Not sure if you’ve noticed, but José has been working on LiveView components which would solve your exact use case. Have a look at the liveview active branches, I’m on mobile right now and can’t link the WIP

Last Post!

LOG67

LOG67

Thanks! I wasn’t aware of this! I think this is exactly what I wanted. I will closely follow the development of this brach. Meanwhile, I continue with my not so elegant approach of rendering the child view using render and injecting the shared event handling code using macros.

Where Next?

Popular in Questions Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
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
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

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
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

We're in Beta

About us Mission Statement