Sha256: 1021e013c9f4970627a15ff49caf9b1d668efb984c7a7c8a784c8b135c7b8b4e
Contents?: true
Size: 1.81 KB
Versions: 25
Compression:
Stored size: 1.81 KB
Contents
# Override Rails handling of confirmation $.rails.allowAction = (element) -> # The message is something like "Are you sure?" message = element.data('confirm') description = element.data('description') # If there's no message, there's no data-confirm attribute, # which means there's nothing to confirm return true unless message # Clone the clicked element (probably a delete link) so we can use it in the dialog box. $link = element.clone() # We don't necessarily want the same styling as the original link/button. .removeAttr('class') # We don't want to pop up another confirmation (recursion) .removeAttr('data-confirm') # We want a button .addClass('btn').addClass('btn-danger') # We want it to sound confirmy .html("Yes, I'm positively certain.") # Create the modal box with the message modal_html = """ <div id="delete-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <a class="close" data-dismiss="modal">×</a> <h3>#{message}</h3> </div> <div class="modal-body"> <p>#{description}</p> </div> <div class="modal-footer"> <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> </div> </div> </div> </div> """ $modal_html = $(modal_html) # Add the new button to the modal box $modal_html.find('.modal-footer').append($link) # Pop it up $modal_html.modal() # Prevent the original link from working return false
Version data entries
25 entries across 25 versions & 1 rubygems