Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

jquery_ujs async confirm

View behaviors.js.coffee
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
$ ->
$.rails.confirm = (message) ->
answer = $.Deferred();
 
modal = $ """
<div class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Delete</h3>
</div>
<div class="modal-body">
<p>#{message}</p>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
<a href="#" class="btn btn-primary">Delete</a>
</div>
</div>
"""
 
modal.on 'click', 'a.btn-primary', (event) ->
event.preventDefault()
answer.resolve()
 
modal.on 'hidden', ->
answer.reject()
 
modal.modal()
 
answer.promise()
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.