neurodynamic
I have a list of html elements generated from a LiveView stream. I want them to show up on the page interspersed with <hr> elements as visual dividers, but this seems to break the stream_delete function. If I display them like this everything works fine
<div id={id} :for={{id, item} <- @streams.items}>
<%= item.name %>
<.link
phx-click={JS.push("delete", value: %{id: item.id}) |> hide("##{item.id}")}
data-confirm="Are you sure?"
>Delete</.link>
</div>
but when I try it like this instead
<.intersperse :let={{id, item}} enum={@streams.items}>
<:separator><hr></:separator>
<div id={id}>
<%= item.name %>
<.link
phx-click={JS.push("delete", value: %{id: item.id}) |> hide("##{item.id}")}
data-confirm="Are you sure?"
>Delete</.link>
</div>
</.intersperse>
the stream_delete function called when the “Delete” button is pressed doesn’t remove the relevant item from the page (though it does successfully delete it from the database). Anyone know why this breaks it and/or if there’s a way to make it work?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
codeanpeace
Are you including
phx-update="stream"in the parent DOM container?Also, what is the intention of
hide("##{item.id}"}inphx-click?neurodynamic
Yup, the
phx-update="stream"and ids are all where you’d expect. I’m not sure what thehide("##{item.id}"}is for, but that’s part of the boilerplate for the delete buttons that get autogenerated bymix phx.gen.live.codeanpeace
Hmm, the DOM
idthat LiveView uses to identify streams are set at different level. Are the.interspersecomponents also setting theiridthe same way which then clashes with the div levelid?neurodynamic
I don’t think the intersperse component creates any sort of independent wrapper element, so for me, with the parent included it looks like
and the rendered html looks like
I am wondering if maybe using
intersperseand with streams might just not be possible, because the separatorhrelements don’t have any way to get assigned their own unique ids. They don’t have access to theidvariable, so I can’t just give them like"#{id}-separatoror something to identify it, and even if I could, my gut would be that the stream implementation probably relies on the assumption that the HTML list created by a stream only has elements directly tied to a specific stream item (trying to find stream rendering in the source code and coming up blank so far).codeanpeace
Hmm, that would make sense – have you tried moving the
<hr>elements into the<div id="item-x">elements or alternatively using those divs as wrappers such that the<hr>elements are no longer siblings with them?Scoping the search to javascript files seems to help.