Closed mindok closed 2 years ago
@mindok thank you so much! Excellent catch. I thought that https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#push_event/3 would route the event to the right component, but that was a wrong assumption. The docs are pretty clear that this is not the case.
I followed your suggestions and now it's working. Let me know if it works for you too.
closed by: ec34db79754d7423824f435210e75779e618eb82
Looks great thanks!
If you have two live selects in the same form, selecting a value for one updates both.
The form is set up as follows:
It appears to be due to the js handleEvents firing for both instances. On my local copy I made a couple of changes to resolve this. I don't know if I am misunderstanding how to use multiple instances, but if these changes make sense, I'm happy to package them into a PR.
I patched the
mounted
in live_select.js to look like this:and the functions that invoke the events in component.ex to look like this: