Confirm Dialog

A confirm dialog is often used if you want the user to verify or accept something. When a confirm dialog pops up, the user will have to click either "OK" or "Cancel" to proceed.
Looking for a commercial license ? Keep your source code proprietary and Buy a Commercial License Today!

Default usage


You create a confirm dialog by invoking alertify.confirm(...)

Calling alertify.confirm() the dialog parameter-less constructor will return the confirm dialog instance. You can use this syntax to modify dialog settings before showing it. Also you can get the dialog instance (singletons only) by invoking alertify.dialog('confirm');


/*
 * @title {String or DOMElement} The dialog title.
 * @message {String or DOMElement} The dialog contents.
 * @onok {Function} Invoked when the user clicks OK button.
 * @oncancel {Function} Invoked when the user clicks Cancel button or closes the dialog.
 *
 * alertify.confirm(title, message, onok, oncancel);
 *
 */
alertify.confirm('Confirm Title', 'Confirm Message', function(){ alertify.success('Ok') }
                , function(){ alertify.error('Cancel')});

Overloads

For convenience, the following overloads are also available:


/*
 * @message {String or DOMElement} The dialog contents.
 *
 *  alertify.confirm(message);
 *
 */
alertify.confirm('Confirm Message');

/*
 * @message {String or DOMElement} The dialog contents.
 * @onok {Function} Invoked when the user clicks OK button.
 *
 *  alertify.confirm(message, onok);
 *
 */  
alertify.confirm('Confirm Message', function(){ alertify.success('Ok') });

/*
 * @message {String or DOMElement} The dialog contents.
 * @onok {Function} Invoked when the user clicks OK button.
 * @oncancel {Function} Invoked when the user clicks Cancel button or closes the dialog.
 *
 *  alertify.confirm(message, onok, oncancel);
 *
 */
alertify.confirm('Confirm Message', function(){ alertify.success('Ok') }, function(){ alertify.error('Cancel')});