Skip to content

Instantly share code, notes, and snippets.

@magicmarkker
Created November 12, 2012 19:24
Show Gist options
  • Save magicmarkker/4061328 to your computer and use it in GitHub Desktop.
Save magicmarkker/4061328 to your computer and use it in GitHub Desktop.
Rails custom dialog confirm box with twitter bootstrap modal
$.rails.allowAction = (element) ->
message = element.data("confirm")
answer = false
return true unless message
if $.rails.fire(element, "confirm")
myCustomConfirmBox message, element
false
myCustomConfirmBox = (message, element) ->
$('.modal .btn-primary').unbind "click"
$("#dialog-confirm .modal-body").html message
$("#dialog-confirm").modal "show"
$("#dialog-confirm .btn-primary").click ->
if element.attr("data-remote")
$.rails.handleRemote element
else
$.rails.handleMethod element
$("#dialog-confirm").modal "hide"
$("#dialog-confirm .modal-body").html ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment