Forked from trey/rails_bootstrap_delete_confirmation_modal.md
Last active
August 29, 2015 14:24
Revisions
-
Senhordim revised this gist
Jul 3, 2015 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,4 @@ ```javascript // Delete confirmation modals -
Trey Piepmeier created this gist
Feb 8, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@  Some JavaScript ```javascript // Delete confirmation modals $('#delete-confirm').on('show', function() { var $submit = $(this).find('.btn-danger'), href = $submit.attr('href'); $submit.attr('href', href.replace('pony', $(this).data('id'))); }); $('.delete-confirm').click(function(e) { e.preventDefault(); $('#delete-confirm').data('id', $(this).data('id')).modal('show'); }); ``` Some HTML ```html <div class="modal fade" id="delete-confirm"> <div class="modal-header"> <a class="close" data-dismiss="modal">×</a> <h3>Delete this thing?</h3> </div> <div class="modal-body"> <p>Be certain, sonny.</p> </div> <div class="modal-footer"> <%= link_to 'Delete', something_path+'/pony', method: :delete, :class => 'btn btn-danger' %> <a href="#" data-dismiss="modal" class="btn">Cancel</a> </div> </div> ``` A well-crafted link: ```html <a href="#delete-confirm" data-id="<%= @something.id %>" class="delete-confirm btn btn-danger"><i class="icon-trash icon-white"></i></a> ```