Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phoenix link confirmation popup appears multiple times

I'm using Elixir 1.7.2 + Phoenix 1.3 and I've a delete link that has a data prompt of "Are you sure?" before confirming the deletion.

are-you-sure

The problem is, when you click the delete button in the application it asks for multiple consecutive "Are you sure?" confirmations (sometimes as many as 6) before it actually allows you to delete.

The code for the delete link is:

<%= link to: project_document_path(conn, :delete, project, document),
          method: :delete,
          data: [confirm: "Are you sure?"] do %>
  <img class="absolute k-w2-5 top-0 left-1" src="/images/delete.svg" />
<% end %>

Has anyone else experienced this behaviour in Phoenix with links that have confirmation prompts and knows how to solve it?

Thanks in advance!

like image 839
Jack Carlisle Avatar asked Sep 14 '18 08:09

Jack Carlisle


1 Answers

This was happening because we were requiring our javascript file in multiple locations, one for each time we were calling a javascript function. We now have one instance of our require in our app.html.eex file which covers our whole view file tree. This is the code that was replicated:

<script src="<%= static_path(@conn, "/js/app.js") %>"></script>

like image 166
Jack Carlisle Avatar answered Nov 09 '22 10:11

Jack Carlisle