trisolaran

trisolaran

Update of LiveComponent fails with error "component ABC with ID XYZ does not exist or it has been removed"

Hi,

I’m rendering a live component in a for loop:

 <%= for mapping_form <- inputs_for(f, :mapping)  do %>
    ...
                <.live_select
                  form={mapping_form}
                  field={:source_field}
                  phx-target={@myself}
                  options={source_field_option_list(@changeset)}
                  update_min_len={0}
                />
<% end %>

“live_select” renders a live component. What I want to do is to update the component dynamically using send_update:

send_update(LiveSelect, id: id, options: options)

This fails with the error:

send_update failed because component LiveSelect with ID "custom_mapping[mapping][0]_source_field_live_select_component" does not exist or it has been removed

However, when I inspect the DOM, I see the live compnent is there and has the expected id custom_mapping[mapping][0]_source_field_live_select_component

I’m kind of puzzled by this issue, as far as I know sending updates to LiveComponents should work even if they’re rendered in a loop.

Wondering if anyone can give me a hint or can think of any reason that would cause the LiveComponent not to be found by LiveView.

Thanks!

P.S: using the new <.inputs_for> component instead of the loop didn’t change anything

Marked As Solved

trisolaran

trisolaran

hahah absolute brain fart :laughing:

I was using the wrong module name: it should be LiveSelect.Component not LiveSelect.

And I wrote the damn library!! I should go back and read my own docs :man_facepalming:

In my defence: It’s been a really hard week for me. I will close this topic and sorry.

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
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
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
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
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
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

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
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
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

We're in Beta

About us Mission Statement