-
-
Save esshka/a5579d29429e351720f9 to your computer and use it in GitHub Desktop.
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
//= require jquery | |
//= require jquery_ujs | |
//= require_tree . | |
// ^ I am assuming that bootstrap3-dialog is in the tree | |
//GLOBAL JQuery Functaionality | |
$(function(){ | |
/*** CONFIRM MODAL OVERRIDE ***/ | |
//override the use of js alert on confirms | |
//requires bootstrap3-dialog from https://github.com/nakupanda/bootstrap3-dialog | |
$.rails.allowAction = function(link){ | |
if( !link.is('[data-confirm]') ) | |
return true; | |
BootstrapDialog.show({ | |
type: BootstrapDialog.TYPE_DANGER, | |
title: 'Confirm', | |
message: link.attr('data-confirm'), | |
buttons: [{ | |
label: 'Accept', | |
cssClass: 'btn-primary', | |
action: function(dialogRef){ | |
link.removeAttr('data-confirm'); | |
link.trigger('click.rails'); | |
dialogRef.close(); | |
} | |
}, { | |
label: 'Cancel', | |
action: function(dialogRef){ | |
dialogRef.close(); | |
} | |
}] | |
}); | |
return false; // always stops the action since code runs asynchronously | |
}; | |
//Other global javascript stuffs | |
//... | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment