Havardpede
I am working on creating a multi-page application form.
I have decided to hide the next-button until there is an answer for each question on the page.
To detect when an answer is updated, I have tried the following:
-
Attaching a
phx-blurto the inputs. This worked, but forced the user to exit the input, which wasnt intuitive enough in certain cases. -
Attaching a
phx-keyupto inputs. I could not find a way to attach a reference to indicate which input was being edited, so I could update the relevant answer. -
Wrapping the inputs in a
<form>withphx-change. This triggered the event correctly, but did not reload the DOM. I even converted the navbar into alive_component, and tried triggering a forced re-render withsend_update/2.
Do you have any ideas on how to handle this case?
Thanks in advance ![]()
Trending in Questions
Other Trending Topics
Latest Phoenix Threads
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #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)
chrismccord
This is the way to go. Can you share your live view / template (or a distilled version) so we can say what could be wrong? Thanks!
Havardpede
Hey @chrismccord appreciate your input
I created the following to replicate the issue:
When editing the answer, the socket is updated with the correct value for :show_button. However, this is not updated in the DOM.
outlog
seems like those assigns doesn’t go on the socket/reply eg you need
this is a bit of OOP vs FP..
is basically a noop in FP - while in OOP it would most likely have mutated “socket”
Havardpede
Oh wow yeah that was obvious. Thank you
Havardpede
@outlog I stored the updated socket. That did not solve it unfortunately.
chrismccord
can you share your new code?
Havardpede
String input

The following code is when using
phx-changein conjunction with a input of typestring.select input

sfusato
I don’t think you are properly pattern matching in your
handle_event. If you do a print to the console inside the function, does it gets printed to the console?If my suspicion is right, start with a bare
valuesin the function head, print that to the console, see the format and then refine your pattern matching.Havardpede
Yes it does in fact call the function, @sfusato
outlog
check your browser console - believe there is a bug in phoenix_live_view.js
InvalidCharacterError: The string contains invalid characters.