ca1989
Hi all,
in a live component I render some checkboxes and a button to check all of them:
...
<%= for x <- @list_of_things do %>
<input type="checkbox"
id=...
name=...
phx-click="some-event"
phx-value-column={elem(x, 1)}
phx-target={@myself}
checked={is_checked?(x, @another_list)}
/>
<% end %>
<button type="button" phx-click={JS.push("check-all", target: @myself)}>
...
Inside the event handler I update @another_list
{:noreply, assign(socket, another_list: [...])}
the is_checked? function gets called (I inspected inside it) and it is returning true a number of times equal to the number of checkboxes.
Anyway, the UI doesn’t show all the checkboxes as checked until I refresh the page.
What am I doing wrong here?
Cheers!
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
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
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
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
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
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
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
cmo
I think you’re going to need an
idand/ornameon those check boxes at least.ca1989
They went missing when I pasted, I have them (I am going to edit the original post)
Malian
I faced the same issue few weeks ago. My checkboxes were inside a
phx-update="stream". In that case, the inner block is not updated, and this is the expected behaviour. Is it your case ?ca1989
Nope, no
phx-updateattr at all.benwilson512
Do you have a form defined around those or not? Can you show a more complete set of code?
ca1989
No, there’s no form around those.
Here is the whole snippet:
This is the
col_checked?functionI have to mention that when the
make-all-columns-visibleevent is handled, the table in the page really show all the columns, only the checkboxes are not updated.soup
Just to sense check, you are updating the
@all_columnsassign and putting the updated value back in the socket assigns right?Since its a component, are the checkbox values getting passed in from a parent? Perhaps there is a value sync issue there?
ca1989
Umm
@all_columnsdoes not change. Doesn’t need to change TBH. So maybe that’s why my checkboxes aren’t re-rendered? The comprehension is simply ignored?Is there any way around this?
Cheers!
soup
Ah sorry, I miscomprehended the comprehension.
There is a erroneous
<span/>tag in the code above, but probably just copy paste bug, I dont think heex would compile as given, probably not the issue.If
@columnsis changing, then it will re-render, so I suspect the updated value isn’t getting propagated to the checkbox component.Is
@columnsowned by the component or the parent view? Who is updating it (the checkbox component or the parent view?) when things are toggled (sounds like its the component by the first post)? Are the checkboxes in the same component as the table? Is it possible thatComponent#update(assigns, socket)is getting called and re-initialising the@columnsto some stale?I guess I would also check another browser just to be sure its not a odd sticky-html-quirk.
ca1989
I believe this is valid heex, equivalent to
<span></span>(90% sure :))Yes,
@columnsis changing, but it is inside a comprehension where@all_columnsis not changing.I can confirm
@columnsis changing because it is used to show and hide table columns (and it’s working fine).@columnsis passed to this component from the parent view, the first time I assign it to@all_columnsand then the checkboxes updates@columns.Tried on other browsers with no luck.