Reputation: 65467
I have some destructive action to be performed, so I think it's Rails way to put such actions behind a PUT or POST (so link_to doesn't work because it only GETs).
I added a button like this:
<%= button_to "Acknowledge", ack_something_path, :method => :put, :confirm => "Sure?" %>
The button works (calls the correct action), but, I can't get Rails to show a "confirm" dialog box.
Any ideas how to do that ?
UPDATE (PROBLEM SOLVED)
I didn't mention that I was including jquery as well as prototype in HEAD
(didn't think it would matter). BUT, when I removed jquery, the confirmation dialog was displayed.
Don't know why this happens, but problem is solved (for now anyway). jquery and prototype do not like to work together it seems.
Upvotes: 2
Views: 5709
Reputation: 1855
I could show the confirm dialog box when I copy your code to my view.
Did you include correct javascript file in the <head>
section? The js file at public/javascripts/rails.js
is needed to enable all the js effect in view helper methods.
You can check whether <%= javascript_include_tag :defaults %>
is in the head
or not.
Upvotes: 2