Just before trying it out, as the title already asks, is it possible to use Phoenix.LiveView.JS within surface components, or have I go for the “hooks” way ?
Yeah, it works with Surface without problems.
Here’s an example
In component module .ex
def hide(id) do
JS.dispatch(%JS{}, "my_event", to: "#myid")
end
In component template .sface
<button :on-click={toggle(id)} type="button">My button</button>