I'm using button_to with :confirm in my html_options, but no confirmation dialog is appearing (in FF & Chrome)
I'm creating a button like this:
<%= button_to "Remove", { :controller => 'notes', :action => 'destroy', :note_id => @note.id },:confirm => "Are y开发者_如何学Cou sure?" %>
This is the output:
<form method="post" action="/notes/destroy?note_id=436" class="button_to"><div><input data-confirm="Are you sure?" type="submit" value="Remove" /><input name="authenticity_token" type="hidden" value="zofUWrh9PllFY+2UqV2qMC9YM20Oij3e1Zvw/wEL/q8=" /></div></form>
The button works fine except there's no confirmation popup when the button is clicked. What am I doing wrong? Thanks for reading.
Are you using Rails 3.0 or above? If so include the javascript files - in the header:
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
Here is a good walk-through:
http://www.simonecarletti.com/blog/2010/06/unobtrusive-javascript-in-rails-3/
精彩评论