Prima.Listbox.JS (Prima v0.3.0)

View Source

JavaScript commands for client-side listbox control.

Summary

Functions

set_value(id, value)

Sets the value of the listbox with the given ID.

The value must match one of the listbox's options; otherwise nothing changes. Dispatches no events unless notify: true is given.

Options

  • :notify - also dispatch input and change on the hidden input, so a parent form's phx-change fires (default: false)

Examples

<button type="button" phx-click={Prima.Listbox.JS.set_value("role-listbox", "viewer")}>
  Reset role
</button>

<button
  type="button"
  phx-click={JS.push("reset") |> Prima.Listbox.JS.set_value("role-listbox", "viewer", notify: true)}
>
  Reset role
</button>

set_value(js, id, value)

set_value(js, id, value, opts)