Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Bootstrap modal confirmation dialog for Rails
# Replace Rails' confirmation dialog with a translatable Bootstrap modal dialog.
# Requires jQuery 1.7, Bootstrap, and i18n-js (
# Translation strings used: confirm.title, confirm.ok, confirm.cancel
$ ->
$.rails.confirm = (message) ->
$("#confirm_dialog > .modal-body").html("<p><i class='icon-warning-sign'></i> " + message + '</p>')
if $('[data-confirm]')
$('body').append("<div class='modal hide' id='confirm_dialog'><div class='modal-header'><a class='close' data-dismiss='modal'>×</a><h3>" + I18n.t('confirm.title') + "</h3></div><div class='modal-body'></div><div class='modal-footer'><a class='btn btn-primary'></a><a href='#' data-dismiss='modal' class='btn'>" + I18n.t('confirm.cancel') + "</a></div></div>")
$('[data-confirm]').each ->
link_elem = $(this) (e) ->
confirm = $('#confirm_dialog > .modal-footer > .btn-primary')
new_confirm = link_elem.clone()
new_confirm.removeAttr('data-confirm id')
new_confirm.attr('class', 'btn btn-primary')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.