2

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.

Zabba
  • 64,285
  • 47
  • 179
  • 207
  • 2
    Actually jQuery and Prototype both define their own `$` method. To solve, call `jQuery.noConflict()` after the jquery lib is included. After that, use `jQuery` for jquery's $ method, and use `$` for prototype's $ method. – PeterWong Dec 15 '10 at 08:43
  • Nice to know, thanks! Also, when I included jQuery before the `javascript_include_tag :defaults`, it worked (i.e. without calling `noConflict()`)! (Note to self: http://www.alfajango.com/blog/rails-prototype-to-jquery/) – Zabba Dec 15 '10 at 08:52

1 Answers1

2

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.

Kevin
  • 1,845
  • 13
  • 12