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
1 Like

Like this…

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

Noticed a downside to the solution: Firefox gives you an option to deactivate the confirmation modal when it arises in the future. Especially for a delete operation, I do not want it to offer such an option. Wonder if there is a way to keep it from doing this.