jQuery - JavaScript | Behavior Layer

Customizable Dialog Box

alertify.alert( message, function () {
    // after clicking OK
});
alertify.confirm( message, function (e) {
    if (e) {
        //after clicking OK
    } else {
        //after clicking Cancel
    }
});
alertify.prompt( message, function (e, str) {
    if (e) {
        // after clicking OK
        // str is the value from the textbox
    } else {
        // after clicking Cancel
    }
});

Customizable Button Labels


alertify.labels = { ok: "OK", cancel: "Cancel" };
// alertify.labels.ok     = "OK";
// alertify.labels.cancel = "Cancel";

Customizable Log Messages

alertify.log( message, type );
alertify.success( message );
// shorthand for alertify.log( message, "success");
alertify.error( message );
// shorthand for alertify.log( message, "error");

The type parameter (optional) gets applied as a class to allow for custom styling.

alertify.log( "This is a custom log", "custom" );
// html
<article class="alertify-log alertify-log-custom">This is a custom log</article>
// css
.alertify-log-custom { }

The same functionality can also be achieved with the extend method.

// set it
alertify.custom = alertify.extend( "custom" );
// use it
alertify.custom( message );