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
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
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
Popular in Discussions
Other popular topics
Latest Phoenix Threads
Chat & Discussions>Discussions
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









