Unfortunately, BootstrapDialog.confirm() is asynchronous, so it does not wait. You form will go ahead with the submission upon clicking of the submit button. To get around this, you have to first prevent this default behavior of the submit button from happening by adding:
$("#btnSave").click(function(e){
e.preventDefault();
This will stop the form from submitting and allow the confirm dialog to show.
Next, you will add code to submit the form when the return from callback is true, do this:
callback: function(result) {
if(result) {
$("#idOfForm").submit();
}
}
Putting together the whole picture:
$("#btnSave").click(function(e){
e.preventDefault();
BootstrapDialog.confirm({
callback: function(result) {
if(result) {
$("#idOfForm").submit();
}
}
});
})