Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

link_to :confirm displays popup twice

This tag with rails 3

<%= link_to 'Destroy', item, :method => :delete,:confirm=>'Are you sure?' %> 

produces this html

<a href="/news/3" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Destroy</a> 

The entry is deleted, the problem is that the popup appears twice.

What could be causing this?

like image 410
user370731 Avatar asked Dec 17 '10 22:12

user370731


2 Answers

I was having this same issue, and spent the better part of an hour looking into it. I found a solution in my situation, and I figured I would share it in case it helps...

My problem was that I had

config.assets.debug = true  

in config/environments/development.rb

Changing that line to

config.assets.debug = false 

fixed the confirmation duplication for me. I found the relevant information in this rails guide to asset pipeline. Hope it helps!

like image 149
BMB Avatar answered Sep 20 '22 08:09

BMB


It sounds like the confirmation handler Javascript in rails.js is being attached twice.

Could you be accidentally including two copies of rails.js via duplication of a javascript_include_tag helper?

like image 36
Scott Avatar answered Sep 22 '22 08:09

Scott