I have a LiveView component that allows users to delete a particular record, we use a data confirm to be sure they actually want to delete the record. However, the popup fires 10 or more times before the record is actually submitted.
<%= link "delete", to: "#",
class: "btn btn-danger",
phx_click: "delete",
phx_value_id: msg.id,
data_confirm: "Are you sure? (Deleted notifications can not be recovered)" %>
This seems to be an issue similar to the one reported here.
I have found that by moving <%= script_tag src: static_path(@conn, "/js/app.js"), defer: true %>
from body
into the head
as Turbolinks recommends does prevent the modal from popping multiple times. Only, now the record does not get deleted. A console error appears:
phoenix_live_view.js:5 Uncaught TypeError: Cannot read property 'getDescendentByEl' of undefined
at e.value (phoenix_live_view.js:5)
at phoenix_live_view.js:5
at Q (phoenix_live_view.js:5)
at e.value (phoenix_live_view.js:5)
at e.value (phoenix_live_view.js:5)
at phoenix_live_view.js:5
at Object.debounce (phoenix_live_view.js:5)
at e.value (phoenix_live_view.js:5)
at phoenix_live_view.js:5
I’m not sure how to proceed on this.