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?
I copy this solution from another post, but this is what worked for me (rails 5)
"remove jquery_ujs from your application.js as rails_ujs is enough for later rails version."
I had included:
//= require jquery //= require jquery-ujs //= require rails-ujs
and after deleting it, all works fine. Solution from: Why am I getting a JQuery alert twice in Rails?
In the layout haml like this have the twice pop up problem
Then I commend it and it works.
In my case jQuery was loaded twice because of the line
//= require_tree .
To prevent this error in application.js and application.css I'm used to create a subdirectory
app/assets/javascript/autorequire
and instead ofrequire_tree .
I dorequire_tree ./autorequire
.So, files in
app/assets/javascript
andapp/assets/stylesheets
are not included automatically/accidentally anymore. I put all my individual .css and .js files into the subdirectory and they are included implicitly. But I can define which files from the top-path are to be included and in which order.Since I do so, I never had troubles by assets not loaded as I expect them to be.
just remove the turbolinks, that worked for me in rails4
This seem to be a bug in Rails. Apparently directives in application.js are not only expanded into individual files when debug mode is enabled, but they are also included in application.js. I haven't looked at the Rails code for this but assume it is due to application.js being the default JavaScript file. If you rename this file to something else, lets say default.js it will in debug mode correctly include the files specified by the directive and default.js will only output JavaScript which is only in that file. Thus not generating duplicate code.
Example:
application.js
//= require jquery_ujs
foo();
Results in:
1) jquery_ujs.js
2) application.js with jquery_ujs contents and foo()
default.js
//= require jquery_ujs
foo();
Results in:
1) jquery_ujs.js
2) default.js with foo()
In my case (Rails 3.2.13), I had to delete rails.js to fix the same problem.
I did not explicitly reference rails.js, nor did changing config.assets.debug help.