-
-
Save asssis/4e7101407a16eff25fc9b2d43d3f4cb9 to your computer and use it in GitHub Desktop.
data-confirm personalizar com switalert
This file contains hidden or 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
<%= javascript_include_tag 'https://unpkg.com/sweetalert/dist/sweetalert.min.js', 'data-turbolinks-track': 'reload' %> | |
//= require jquery | |
//= require jquery_ujs | |
$.rails.allowAction = function(element) { | |
var message = element.attr('data-confirm'); | |
if (!message) { return true; } | |
swal({ | |
title: "Confirmação?", | |
text: message, | |
type: "warning", | |
showCancelButton: true, | |
confirmButtonClass: "btn-danger", | |
confirmButtonText: "SIM", | |
cancelButtonText: "NÃO", | |
closeOnConfirm: false, | |
closeOnCancel: true | |
}, | |
function(isConfirm) { | |
if (isConfirm) { | |
element.removeAttr('data-confirm'); | |
element.trigger('click.rails') | |
} | |
}); | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment