This example demonstrates the new t-string API for JS commands.
Import js from pyview and use it directly in your templates.
JS Commands let you update the DOM without making a trip to the server.
Toggle me!
Watch my classes change!
Dispatch sends custom JavaScript events that you can listen to with window.addEventListener.
This example also shows command chaining - dispatching an event AND adding a class in one click.
[["dispatch", {"event": "copy-to-clipboard", "to": "#copy-text"}]]
Push sends events to your LiveView, similar to phx-click.
Chain it with other commands for optimistic UI updates!
A common pattern: hide the element immediately (optimistic UI) while sending the delete event to the server.
Chains show/hide with push_focus / pop_focus to save and restore focus for accessibility.