Skip to content

Instantly share code, notes, and snippets.

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

This comment has been minimized.

Copy link
Owner Author

@Genkilabs Genkilabs commented May 15, 2014


  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:


This comment has been minimized.

Copy link

@mahemoff mahemoff commented Oct 22, 2014

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


This comment has been minimized.

Copy link

@silversilkroad silversilkroad commented Feb 23, 2015

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


This comment has been minimized.

Copy link

@trincema trincema commented Jan 28, 2016

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


This comment has been minimized.

Copy link

@Ramyz986 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