Change the order of Bootbox buttons
The recent version 5 of bootbox finally allows you to invert the OK and Cancel buttons for your confirmation dialog boxes.
HTML
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.0/highlight.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.0/languages/javascript.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootbox@5.1.3/dist/bootbox.all.min.js"></script>
<div align="center">
<br><br>
<a class="btn btn-primary" onclick="doItWrong()">Click here to do it the wrong way</a><br><br>
<a class="btn btn-primary" onclick="doItRight()">Click here to do it the right way</a>
</div>
JavaScript
function doItRight() {
bootbox.confirm({
title: "Please confirm",
swapButtonOrder:true,
centerVertical: true,
message: "Are you sure you want to do it?",
callback: function(result) {
//do something
}
});
}
function doItWrong() {
bootbox.confirm({
title: "Please confirm",
swapButtonOrder:false,
centerVertical: true,
message: "Are you sure you want to do it?",
callback: function(result) {
//do something
}
});
}