Using bootbox the show event is not fired

alloyoussef picture alloyoussef · Apr 21, 2014 · Viewed 16.6k times · Source

I'm not able to catch the show event for the bootbox.confirm dialog in order to do some css adjustments to the dialog before showing it.

I tried things like the followings but didn't succeed:

$(document).on("show.bs.modal", function (event) {...});
$(document).on("show", function (event) {...});
$(document).on("show", ".bootbox", function (event) {...});

Answer

codephobia picture codephobia · Apr 23, 2014

This should work for you using Bootbox 4.x.x and Bootstrap 3.x.x:

var box = bootbox.dialog({
  message: '',
  title: '',
  buttons: {},
  show: false
});

box.on("shown.bs.modal", function() {
  alert('it worked!');
});

box.modal('show');

or like this:

$(document).on("shown.bs.modal", function (event) {...});