Open LostKobrakai opened 2 weeks ago
The documentation says:
If you are pushing events from a hook to a component, then you must pass an element, created with element/3, as first argument and it must point to a single element on the page with a phx-target attribute in it:
The requirement that it must be a single element seems inconvenient, especially when my phx-hook (and therefore phx-target) is on a div containing other elements.
I had a test for a sortable list <div phx-hook="Sortable"
working just fine with render_hook(view, "update-sorting", %{"ids" => sort})
, but the moment I tried to use it in the Table component <tbody phx-hook="Sortable" phx-target="sortable-table
, render_hook no longer returns the updated result, or complains about the selector not returning a single element.
Environment
Actual behavior
Using
render_hook(element(view, "#hook-el-id"), "event", map)
requires#hook-el-id
to have aphx-target
attribute for therender_hook/3
to work.Expected behavior
The
phx-target
attribute seems to not be required outside of tests and it would seems to hold the same value asdata-phx-component
anyways. My expectation would be thatphx-target
shouldn't be required forrender_hook/3
as well.