Submitted by Damien on
Tags:
While working on a site in Rails tonight I was adding a button_to
that I wanted a JS confirmation requester. Well, based on my albeit beginner knowledge of Rails I thought the following would work:
[source:ruby]
< %= button_to "Empty Cart", :action => :empty, :confirm => "Really empty your cart?" %>
[/source]
As it turned out this wouldn't work, it kept adding "?confirm=Really empty your cart?" to the URL instead of doing a popup. A bit of fiddling later I realized that to work correctly the additional arguments to button_to need to be arrays, e.g.:
[source:ruby]
< %= button_to "Empty Cart", {:action => :empty}, {:confirm => "Really empty your cart?"} %>
[/source]