As explained later in the blog post, this event was not supposed to come to my LiveView, rather it was supposed to be caught by javascript and call JS.execute() on it.
Quick clarification: JS.toggle doesn’t toggle a class on an element, it toggles its visibility by modifying its display property.
Your code looks good and should just work™
This looks like the string in the phx-click attribute is not being interpreted by LV as a JS command, but it’s instead being used as the name of the event to send to the server, as if you had written: phx-click="event_name".
Never came across this before. Could you maybe share your app.js?
Thanks. Nothing suspicious in here AFAICS. If you can create a repository with a minimal application that reproduces the issue, I’d be happy to take a look.