Reputation: 10062
I'm trying to setup a link that deletes a database entry, and everything works as intended, it just doesn't ask for confirmation first. I think I've done everything right, I'm testing this in firefox on ubuntu.
<%= link_to "Delete", @post, :confirm => "Are you sure you want to delete?", :method => :delete %>
any help is appreciated.
Upvotes: 1
Views: 104
Reputation: 44370
Read the documentation carefully
:
:data
- This option can be used to add custom data attributes.
Data attributes
confirm: 'question?'
- This will allow the unobtrusive JavaScript driver to prompt with the question specified (in this case, the resulting text would be question?. If the user accepts, the link is processed normally, otherwise no action is taken.
Your link_to
should be like this:
<%= link_to "Delete", @post, data: { :confirm => "Question?", :method => :delete } %>
Look at this if you use a version before 4.0.2
Upvotes: 3
Reputation:
Do you have this lines in your application.js file ?
//= require jquery
//= require jquery_ujs
Upvotes: 0