Skip to content

How to Use

fabien-d edited this page Dec 1, 2012 · 5 revisions

Installing

Straight into HTML

<!-- ideally at the bottom of the page -->
<!-- also works in the <head> -->
<script src="PATH_TO_FILE/alertify.min.js"></script>

AMD (e.g requirejs)

define(["PATH_TO_FILE/alertify.min"], function (alertify) {
	// alertify is now available
});

Usage

alertify.log( message, type );

shorthand available to "success" and "error"

alertify.success( message ); // same as alertify.log( message, "success" );
alertify.error( message );   // same as alertify.log( message, "error" );

extend method allows for custom methods

alertify.custom = alertify.extend( "custom" );
alertify.custom( message ); // same as alertify.log( message, "custom" );
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
	}
});
alertify.alert(...).confirm(...)...
Clone this wiki locally