Phoenix.LiveView.JS commands not working

I switched from alpine to JS commands for simple interactions like toggles etc. One of which is the standard mobile menu. It works fine on the main page but for some reason it does not work on pages created by phx.gen.auth. Am I missing something ? The navbar is in root.html.heex template.

Js commands (sadly) only work on live pages.

1 Like

I am slightly confused here. It is in root template not liveview per se. also it is present on every page.
So is it like if I’ll render livew withing root it works but when regular pages are rendered within root it doesn’t ?

Exactly that. The root.html is never live (as in the server can change the html), but it seems JS commands work on the whole page. But JS commands are only initialized if the page is a LiveView. They even used to not work if the LV is not connected in the past.

Thank you.
I like phoenix and enjoy elixir but those little quirks not really documented anywhere are driving me nuts.

In the end phoenix live view is still pre 1.0. Things are not necessarily stable yet and documentation efforts will likely remain incomplete till that changes.