DaAnalyst

DaAnalyst

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.

Showing Posts 1 to 3

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?

DaAnalyst

DaAnalyst OP

Unfortunately, I find components too heavy for the use with table/grid rows because of their helper index structure included along with any change.
With hundreds of rows, the helper structure becomes quite burdensome.

In addition to this, since the row component itself is made up of a list of cells, somehow it always sends the entire row (all cells) even if just a couple of characters have changed in a single cell. When binary comparing the HTML output it is identical but for the couple of bytes, yet the JS object in the debugging mode gets to contain the entire row and the accompanying structure. It could be me, but I did absolutely everything to follow the rules and yet somehow that diffing within a component does not work properly (still using v0.14.7 though).

UPDATE: Please note that the only option that I haven’t tried so far is the row components in appended container. However, if the behavior is as provided in the documentation, a component will get replaced as a whole, right/wrong?

DaAnalyst

DaAnalyst OP

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

— All posts loaded —

Where Next? Top

Trending in Discussions Top

wmnnd
Hey folks, I wanted to share with you a project I’ve been working on for a while: It’s an Open Source (AGPLv3) newsletter tool. Think Ma...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
sntran
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New
Ganna
Hi everyone, I have 8 years of production experience with Erlang/OTP and I’m just starting to get to know Elixir. What would you learn f...
New
johnkirkham
A note on form. Joe Armstrong, co-creator of the Erlang programming language, died in April 2019. What follows is a work of narrative non...
New
gtcode
I’ve been tinkering with Lynx (by José) via hold_ledger. I used AI to write the code, a separate specification, the tests, and the Lean p...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews