Skip to content

Instantly share code, notes, and snippets.

@ayezee33
Created August 3, 2016 14:55
Show Gist options
  • Save ayezee33/962a89a61718ca9ea50401e2f9e4ec0b to your computer and use it in GitHub Desktop.
Save ayezee33/962a89a61718ca9ea50401e2f9e4ec0b to your computer and use it in GitHub Desktop.
Sweet Alert Confirm override allowAction method call
//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