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

Where Next?

Popular in Questions Top

Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
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 43622 214
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
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement