Commands for the JavaScript hooks of the components, to use in phx-click
and other bindings.
Summary
Functions
Hides the modal with the given ID.
Shows the modal with the given ID.
Shows the tab with the given index of the tabs/1 component with the given
ID.
Functions
@spec hide_modal(Phoenix.LiveView.JS.t(), String.t()) :: Phoenix.LiveView.JS.t()
Hides the modal with the given ID.
The component needs its JavaScript hook registered, since this function uses
the hook to call close() on the dialog.
Example
<.link phx-click={Doggo.JS.hide_modal("pet-modal")}>hide</.link>
@spec show_modal(Phoenix.LiveView.JS.t(), String.t()) :: Phoenix.LiveView.JS.t()
Shows the modal with the given ID.
The component needs its JavaScript hook registered, since this function uses
the hook to call showModal() on the dialog.
Example
<.link phx-click={Doggo.JS.show_modal("pet-modal")}>show</.link>
@spec show_tab(Phoenix.LiveView.JS.t(), String.t(), integer()) :: Phoenix.LiveView.JS.t()
Shows the tab with the given index of the tabs/1 component with the given
ID.
The index is one-based. The component needs its JavaScript hook registered, since this function uses the hook to select the tab.
Example
Doggo.JS.show_tab("my-tabs", 2)