js.Dialog Documentation Index:

Simple Dialogs: Dialog.alert
Dialog.confirm
Dialog.prompt
Base Classes: Dialog.core
Dialog.simple
Information: Callbacks
Settings: Dialog.settings Utilities: Functions

js.Dialog

Because it’s the 21st century, baby

Dialog.confirm()

Just like Dialog.alert, this function is intended as a replacement for JavaScript’s buit-in confirm() function. It is based on the Dialog.simple class, and understands the same callbacks and parameters.

However, since this dialog is asynchronous, i.e. the program flow does not wait until the user closes the dialog, you need to use the onConfirm and onCancel-callbacks for any code you want to perform after the user dismisses the dialog.

Dialog.confirm('Do you really want to do this?', {
	   onConfirm: function(dlg) {
	      alert('You pressed OK.');
	   },
	   onCancel: function(dlg) {
	      alert('You cancelled.');
	   }
});

As you might imagine, onCancel gets called whenever the user clicks on the Cancel-button (actually button0 internally) while onConfirm runs if the OK-button (button1) is activated.

But there is one more thing about it: both these callback functions may return a boolean value. If you return true (or in fact not return anything at all), everything works as normal, but if you return false, the dialog will not be closed but stays open.

Note: If the user clicks the closebox (the little × in the title bar), this will also activate the onCancel callback.