I've been playing around with bootbox and am currently using a bootstrap.confirm dialog to confirm a user action. However i would like my dialog to have a title and a close button (preference really)
Heres my code for boot box
bootbox.confirm("Are you sure you want to delete the selected task?", function(result) {
if (result == true) {
//do something
}
});
And the code to append a title
$(".bootbox").prepend("<div class=\"modal-header\"><a href=\"javascript:;\" class=\"close\">×</a><h3>Confirm Delete</h3></div>");
Problem is i dont know how to get it to fire before the dialog loads. Any help?
Worked this one out
$("body").on("show", ".bootbox", function () {
/* Dont add header again if div has been added */
if (!$(".modal-header")[0]) {
$(".bootbox").prepend("<div class=\"modal-header\"><a href=\"javascript:;\" class=\"close\">×</a><h3>Confirm Delete</h3></div>");
}
});
Basically prepend is called as the bootbox is launched, so by the time the modal is visible the title has been added. Also had to add a check to make sure the title is only appended once