Best way to implement confirmation popup on a button in liveview?

In a traditional Phoenix app, I have a link to delete a list that has a browser popup for confirmation:

<%= link("Delete",
   to: Routes.list_path(@socket, :delete, list.id),
   method: :delete,
   data: [confirm: "Are you sure?"]
) %>

What is the best way to do this on a LiveView button?

defmodule MyWeb.ListLive do

   def handle_event("delete", %{"list_id" => id}, socket) do
    #popup
  end

   def render(assigns) do
  ~H"""
    <button phx-click="delete">
      Delete
    </button>
  """
  end

end

Like this…

<button phx-click="delete" data-confirm="Are you sure?">
4 Likes