I am switching to Twitter Bootstrap 2.1.1.
I have a modal with a button to delete but it does not work. In previous bootstrap version it worked OK. Rails version is 3.1
Here is the code
<a title="<%= t('delete') %>" id="delete" class="label" href="#myModal-<%= post.id %>" data-toggle="modal"><%= t('delete') %></a>
the modal
<div class="modal hide" id="myModal-<%= post.id %>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t('delete_this_question') %></h3>
</div>
<div class="modal-body">
<p><%= raw post.text %></p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t('cancel') %></button>
<%= link_to(t('delete'), { :controller => 'posts', :action => 'destroy', :id => post.id } ,:method => :delete, :class => 'btn btn-primary') %>
</div>
</div>
But it does not work. Rails receives a GET and shows the post, but it does not destroy it.
Any idea? Thanks
I found the following solution on http://rors.org/demos/custom-confirm-in-rails
You can use this completely unobtrusively without having to have a custom delete link or modal content in your view. So in my view I have the standard Rails link (only adding some classes to use the Bootstrap styles):
And the following in /app/assets/javascripts/bootstrap-confirmation.js.coffee
If you want more post specific details in your modal you can always include them as data- attributes in your delete link (just like
data-confirmis used to display the confirmation message.)