Skip to content

Instantly share code, notes, and snippets.

Last active November 18, 2017 11:16
What would you like to do?
Bootstrap 3 modals in Rails 4 confirms using bootstrap3-dialog JS plugin
//= require jquery
//= require jquery_ujs
//= require_tree .
// ^ I am assuming that bootstrap3-dialog is in the tree
//GLOBAL JQuery Functaionality
//override the use of js alert on confirms
//requires bootstrap3-dialog from
$.rails.allowAction = function(link){
if( !'[data-confirm]') )
return true;{
type: BootstrapDialog.TYPE_DANGER,
title: 'Confirm',
message: link.attr('data-confirm'),
buttons: [{
label: 'Accept',
cssClass: 'btn-primary',
action: function(dialogRef){
}, {
label: 'Cancel',
action: function(dialogRef){
return false; // always stops the action since code runs asynchronously
//Other global javascript stuffs
Copy link


  1. Put bootstrap-dialog.js in app/assets/javascripts and bootstrap-dialog.css in app/assets/stylesheets/screen
  2. Copy snippet into application.js as shown.
  3. Done.

More info on customization here:
Core Project:

Copy link

Minor nit, but I suggest putting it in a separate file and requiring it so that application.js is purely require statements.

Copy link

PLEASE SOS. I need example toggle Bootsrap dialog using a simple button or link. How to do? as you see in the examples NAKUPANDA repository the demo is using CODE SOURCE RUNNABLE. i want the code to be HIDDEN and launched from a simple button or menu link. thanks in advance

Copy link

How can I connect this with AngularJS? ng-model does not work in an input form inside message

Copy link

Ramyz986 commented Feb 2, 2016

how do i use auto destroy !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment