I have a form and want to intercept form submission to display a confirmation dialog using bootbox.
- User enters some data
- User hits submit
- A confirmation dialog is shown
If the user hits OK
, then the form should submit, if not it should just stay on the page.
I tried this:
$('#myForm').submit(function() {
return bootbox.confirm("Are you sure?");
});
However, bootbox.confirm()
immediately returns, the confirmation dialog is hidden again.
I then noticed that there is a callback parameter on bootbox.confirm()
. However, if I'm to call $('#myForm').submit()
from the callback, this will obviously just show the confirmation dialog again.
So what is the proper way to confirm form submission?