I am using Rails jquery ujs for handling ajax within my app. Also I am using a the confirm
option for destroying any records.
As my current setup, I have hooked up a loading overlay screen on click of data-remote=true
link.
All I wanted to know is: Is there a way I can hook a callback event when a user clicks cancel
on the confirm box and I can close the loader overlay.
Yes, you can. Pass in the response object. In CoffeeScript.
$('selector').on 'confirm:complete', (e, response) ->
if response
# User confirmed
else
# User cancelled.
In Javascript:
$('selector').on('confirm:complete', function(e, response) {
if(response) {
// User confirmed
}
else {
// User cancelled.
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With