Why doesn't the `button tag` display a confirmation dialog?
2 answers
Which version of rails are you using?
Revert :confirm
in favor of option :data => { :confirm => 'Text' }
https://github.com/rails/rails/commit/fc092a9cba5fceec38358072e50e09250cf58840
# I am using 3.2.11 and this works
<%= button_tag(:name => 'destroy', :class => "btn btn-danger", :data => {:confirm => 'Are you sure?'}) do %>
Remove
<% end %>
# this will output <button name="destroy" confirm="Are you sure?" class="btn btn-danger">Remove</button>
# notice confirm is a tag attribute, which won't be picked up by javascript
<%= button_tag(:name => 'destroy', :class => "btn btn-danger", :confirm => 'Are you sure?') do %>
Remove
<% end %>
If you are not using firebug, I highly recommend that you use it.
https://addons.mozilla.org/en-US/firefox/addon/firebug/
Always check the output HTML before diving into ruby.
+2
source to share