JS LiveView issue

Hi All.

I’m just trying out the new Phoenix.LiveView.JS functionality in Liveview 0.17 (JS.hide and JS.show). I’ve defined the following component.

  def hide(assigns) do
    ~H"""
      <div id="item">My Item</div>

      <button phx-click={JS.hide(to: "#item")}>
        hide!
      </button>

      <button pxh-click={JS.show(to: "#item")}> 
        show!
      </button>
    """
  end

when I use the component in my liveview the hide works and hides the element as expected but the show doesn’t. As the above component is taken directly from the docs I wondered if anyone had any ideas why it isn’t working?

cheers

Dave

1 Like

There is a typo in the second phx-click attribute name :slight_smile:

2 Likes

Doh!!!

Teach me to copy and paste from the docs :wink:

Thanks @mcrumm

cheers

Dave