Created
December 26, 2014 10:33
-
-
Save josephrexme/fc495bae88ca4811e446 to your computer and use it in GitHub Desktop.
UJS: Continue execution of ajax request in a callback after altering with ajax:beforeSend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready -> | |
$('[id^="edit_department"').on("ajax:success", (e, data, status, xhr) -> | |
$(this).append "<p class='fr'>Updated Succesfully</p>" | |
$(this).children('.fr').delay(2000).fadeOut() | |
).on "ajax:error", (e, data, status, error) -> | |
$(this).append "<p class='fr'>Failed to update</p>" | |
$('.content>.fr span:last-of-type>a').on "ajax:beforeSend", (xhr, settings) -> | |
swal | |
title: "Are you sure?" | |
text: "You will not be able to undo this!" | |
type: "warning" | |
showCancelButton: true | |
confirmButtonColor: "#DD6B55" | |
confirmButtonText: "Yes, delete it!" | |
closeOnConfirm: false | |
, -> | |
# should send the request here | |
swal "Deleted!", "Department has been deleted.", "success" | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment