Toggle Show Hide on Client in Liveview

From ElixirBlocks
Jump to: navigation, search

This is a working example:

defmodule AppWeb.PageLive do
  use AppWeb, :live_view
  def mount(_params, _session, socket)  do
  {:ok, socket}
  end


  def render(assigns) do
    ~H"""
       <div phx-click={JS.toggle(to: "#item")} > CLICK ME </div>

       <div id="item"> hi there </div>
  """
  end

end