Created
August 3, 2016 14:55
-
-
Save ayezee33/962a89a61718ca9ea50401e2f9e4ec0b to your computer and use it in GitHub Desktop.
Sweet Alert Confirm override allowAction method call
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
//Override the default confirm dialog by rails | |
$.rails.allowAction = function(link){ | |
if (link.data("confirm") == undefined){ | |
return true; | |
} | |
$.rails.showConfirmationDialog(link); | |
return false; | |
} | |
//User click confirm button | |
$.rails.confirmed = function(link){ | |
link.data("confirm", null); | |
link.trigger("click.rails"); | |
} | |
//Display the confirmation dialog | |
$.rails.showConfirmationDialog = function(link){ | |
var message = link.data("confirm"); | |
swal({ | |
title: message, | |
type: 'warning', | |
confirmButtonText: 'Sure', | |
confirmButtonColor: '#2acbb3', | |
showCancelButton: true | |
}).then(function(e){ | |
$.rails.confirmed(link); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment