Skip to main content

SweetAlert integration

Rails • Asked by Michael Kibet

Michael Kibet (50 XP) on

I was able to intergrate sweetAlert properly(*not using the gem but by including the files manually in vendor *)and overiding the rails defaults as follows in the application.js file=>

$.rails.allowAction = function(link){
  if ("confirm") == undefined){
    return true;
  return false;

//User click confirm button
$.rails.confirmed = function(link){"confirm", null);

//Display the confirmation dialog
$.rails.showConfirmationDialog = function(link){
  var message ="confirm");
    title: message,
    type: 'warning',
    confirmButtonText: 'Sure',
    confirmButtonColor: '#2acbb3',
    showCancelButton: true

But the problem comes when I click on the delete button, the dialog box occurs for a very short and doesn't even allow me to either confirm nor deny.
*So I am asking how am i going to slow the dialog box down or make it persistent until a choice is made *

Chris Oliver (162,220 XP) on

Hey Michael,

Not quite sure what's going on there, but any reason you're not using the gem? It already hooks into the standard rails data-confirm stuff and makes this seamless and you can customize the colors and buttons like usual.

Login or create an account to join the conversation.