Use SweetAlert for confirmation dialog

This commit is contained in:
Davide Bellini
2015-10-01 23:28:01 +02:00
parent e59a490878
commit 3fca767624

View File

@@ -48,7 +48,17 @@ $(function() {
return methodForm;
})
.removeAttr('href')
.attr('onclick', ' if ($(this).hasClass(\'confirm-action\')) { if(confirm("Are you sure you want to do this?")) { $(this).find("form").submit(); } } else { $(this).find("form").submit(); }');
.on('click', function() {
var button = $(this);
if (button.hasClass('confirm-action')) {
askConfirmation(function() {
button.find("form").submit();
});
} else {
button.find("form").submit();
}
});
// Messenger config
Messenger.options = {
@@ -351,3 +361,16 @@ $(function() {
.addClass("active");
}
});
function askConfirmation(callback) {
swal({
type: "warning",
title: "Confirm your action",
text: "Are you sure you want to do this ?",
confirmButtonText: "Yes",
confirmButtonColor: "#FF6F6F",
showCancelButton: true
}, function() {
callback();
});
}