DaAnalyst

DaAnalyst

Feature: Arbitrary element replacement

Desired behavior:

The ability to define a segregated container with, say, phx-update=“cross-replace” containing the elements which LiveView then uses to replace elements with the corresponding ids in their respective appended/prepended containers within the same template.
The “cross-replace” container is discarded once the operation is finished.
This is virtually the same feature that LiveView already does when replacing elements in an appended/prepended container, the only difference here being the support for cross-container replacement.

Purpose:

Use cases dealing with more than a single dimension of elements (e.g. a table/grid) typically require a more detailed element replacement then just having their top-dimension entries (e.g. rows) appended and then sorted in the JS code. With the majority of changes occurring at the level of a single element, it is suboptimal to have LiveView transfer the entire rows.

The reason why this feature cannot be done safely at an application level is hooks - the elements getting replaced require their hook related listeners removed by LV.

@josevalim Please share your thoughts on the matter even if you choose not to consider this enhancement request.

UPDATE: Another option is for client code to alter individual attributes of an element instead of having it replaced with the suggested feature, but the limitations here are substantial.

First Post!

josevalim

josevalim

Creator of Elixir

From your description, it feels like you should make each table row a live component. In this scenario, you can change each row, piece by piece, or even transfer it altogether. How is your proposal different from using components as above?

Last Post!

DaAnalyst

DaAnalyst

Just to let you know it’s that last option that actually works as desired.
To sum it up, the table/grid optimal solution:

  • rows: no components, just appended container + JS removal of the marked for deletion and positioning of inserts on updated
  • cells: components

Thanks,
Damir

Where Next?

Popular in Discussions Top

AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31771 143
New
joeerl
I’m playing with Elixir - It’s fun. I think @rvirding does give Elixir courses these days. Re: files and database - when I given Erlang ...
New
pillaiindu
In django there is a cache framework backed by memcached. Rails also puts a lot of emphasis on caching, and even the idea of russian-doll...
New
wmnnd
The Go vs Elixir thread got me thinking: Would it be too hard to implement a simple mechanism for creating Go-style static app binaries f...
New
AstonJ
If so I (and hopefully others!) might have some tips for you :slight_smile: But first, please say which area you’re finding most challen...
New
lucaong
Hello Elixir and Nerves community, I have been working for a while on an open-source embedded key-value database for Elixir, that I call...
230 14403 124
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54260 488
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement