jQuery framework provides alertify.js plugin that provides pre-designed customizable notification system along with interactive browser dialogs. This extensible and themeable plugin is very useful for developers providing an optimized version of alert messages with stacking up to feature.
This small library system effectively display confirmation pop ups, success or error alerts, and prompt messages with queued dialogs which can be extensively used in debugging process.
Example 1: It is easy to understand, customize and implement in your code. It does not depend on any third party libraries but easily integrate with them. The following code demonstrates the beautiful dialog boxes with its stacking up feature.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>jQuery Alertify Plugin</title>
<link rel="stylesheet" href="alertify.core.css" />
<link rel="stylesheet" href="alertify.default.css" id="linkID" />
<script src="http://code.jquery.com/jquery-1.9.1.js">
</script>
<script src="alertify.min.js"></script>
<style>
.alertify-log-custom {
background: green;
}
.height {
height: 10px;
}
</style>
</head>
<body>
<h1 style="color:green">GeeksforGeeks</h1>
<b> jQuery Alertify Plugin</b>
<div class="height"></div><br>
<b>Alertify Dialogs</b>
<div class="height"></div>
<a href="#" id="alertID">Click Alert Dialog</a><br>
<a href="#" id="promptID">Click Prompt Dialog</a><br>
<a href="#" id="confirmID">Click Confirm Dialog</a><br>
<a href="#" id="focusID">Click Button Focus</a><br>
<a href="#" id="labelsID">Click Custom Labels</a><br>
<a href="#" id="orderID">Click Button Order</a>
<script>
function reset() {
$("#linkID").attr("href", "alertify.default.css");
alertify.set({
labels: {
ok: "OK",
cancel: "Cancel"
},
delay: 4000,
buttonFocus: "ok",
buttonReverse: false
});
}
// Alertify Standard Dialog boxes
$("#alertID").on('click', function () {
reset();
alertify.alert("Welcome GFG !");
alertify.alert("Alertify alert dialog");
return false;
});
$("#confirmID").on('click', function () {
reset();
alertify.confirm(
"Please confirm the dialog box ", function (event) {
if (event) {
alertify.success(
"You have clicked OK to confirm our"
+ " terms and conditions.");
} else {
alertify.error(
"You have clicked Cancel not to confirm.");
}
});
return false;
});
$("#promptID").on('click', function () {
reset();
alertify.prompt(
"This is a prompt dialog box", function (event, string) {
if (event) {
alertify.success(
"You have clicked OK and typed: " + string);
} else {
alertify.error(
"You have clicked Cancel");
}
}, "Please enter, this is default value");
return false;
});
$("#success").on('click', function () {
reset();
alertify.success("Success message");
return false;
});
$("#error").on('click', function () {
reset();
alertify.error("Error message");
return false;
});
$("#labelsID").on('click', function () {
reset();
alertify.set({ labels: { ok: "Accept", cancel: "Deny" } });
alertify.confirm(
"Confirm dialog with custom button labels",
function (event) {
if (event) {
alertify.success("You have clicked OK");
} else {
alertify.error("You have clicked Cancel");
}
});
return false;
});
$("#focusID").on('click', function () {
reset();
alertify.set({ buttonFocus: "cancel" });
alertify.confirm(
"Confirm dialog with cancel button focused",
function (event) {
if (event) {
alertify.success("You have clicked OK");
} else {
alertify.error("You have clicked Cancel");
}
});
return false;
});
$("#orderID").on('click', function () {
reset();
alertify.set({ buttonReverse: true });
alertify.confirm(
"Confirm dialog with reversed button order",
function (event) {
if (event) {
alertify.success("You have clicked OK");
} else {
alertify.error("You have clicked Cancel");
}
});
return false;
});
</script>
</body>
</html>
Output:
Example 2: The following code demonstrates the use of log messages from alertify.js plugin.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>jQuery Alertify Plugin</title>
<link rel="stylesheet" href="alertify.core.css" />
<link rel="stylesheet"
href="alertify.default.css" id="linkID" />
<script src=
"http://code.jquery.com/jquery-1.9.1.js">
</script>
<script src="alertify.min.js"></script>
<style>
.alertify-log-custom {
background: green;
}
.height {
height: 10px;
}
</style>
</head>
<body>
<h1 style="color:green">GeeksforGeeks</h1>
<b> jQuery Alertify Plugin</b>
<div class="height"> </div><br>
<b>Alertify Logs</b>
<div class="height"> </div>
<a href="#" id="notificationID">Standard Log</a><br>
<a href="#" id="successID">Success Log</a><br>
<a href="#" id="errorID">Error Log</a><br>
<a href="#" id="customID">Custom Log</a><br>
<a href="#" id="delayID">Hide in 9 seconds</a><br>
<a href="#" id="foreverID">Persistent Log</a>
<script>
function reset() {
$("#linkID").attr("href", "alertify.default.css");
alertify.set({
labels: {
ok: "OK",
cancel: "Cancel"
},
delay: 4000,
buttonFocus: "ok",
buttonReverse: false
});
}
$("#notificationID").on('click', function () {
reset();
alertify.log("Standard log message");
return false;
});
$("#successID").on('click', function () {
reset();
alertify.success("Success log message");
return false;
});
$("#errorID").on('click', function () {
reset();
alertify.error("Error log message");
return false;
});
// Custom Properties
$("#delayID").on('click', function () {
reset();
alertify.set({ delay: 9000 });
alertify.log("Hiding in 9 seconds");
return false;
});
$("#foreverID").on('click', function () {
reset();
alertify.log("It will stay until clicked", "", 0);
return false;
});
// Custom Log message
$("#customID").on('click', function () {
reset();
alertify.custom = alertify.extend("custom");
alertify.custom("Its a custom log message");
return false;
});
</script>
</body>
</html>
Output:
Example 3: The following code demonstrates how to implement themeable dialogs and make ajax calls using notification messages as shown in the code.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>jQuery Alertify Plugin</title>
<link rel="stylesheet" href="alertify.core.css" />
<link rel="stylesheet"
href="alertify.default.css" id="linkID" />
<script src=
"http://code.jquery.com/jquery-1.9.1.js">
</script>
<script src="alertify.min.js"></script>
<style>
.alertify-log-custom {
background: green;
}
.height {
height: 10px;
}
</style>
</head>
<body>
<h1 style="color:green">GeeksforGeeks</h1>
<b> jQuery Alertify Plugin</b>
<div class="height"> </div><br>
<b>Ajax Multiple Dialogs</b>
<div class="height"> </div>
<a href="#" id="ajax">
Ajax with Multiple Dialog</a>
<div class="height"> </div><br />
<b>Custom Bootstrap Themes</b>
<div class="height"> </div>
<a href="#" id="bootstrap">Bootstrap Theme</a>
<script>
function reset() {
$("#linkID").attr("href", "alertify.default.css");
alertify.set({
labels: {
ok: "OK",
cancel: "Cancel"
},
delay: 4000,
buttonFocus: "ok",
buttonReverse: false
});
}
// Ajax call
$("#ajax").on("click", function () {
reset();
alertify.confirm("Confirm?", function (event) {
if (event) {
alertify.alert("Successful Ajax call after OK");
} else {
alertify.alert("Successful Ajax call after Cancel");
}
});
});
// Custom Themes
$("#bootstrap").on('click', function () {
reset();
$("#linkID").attr("href", "alertify.bootstrap.css");
alertify.prompt(
"It prompts dialog with bootstrap theme",
function (event) {
if (event) {
alertify.success("You have clicked OK");
} else {
alertify.error("You have clicked Cancel");
}
}, "This is Default Value");
return false;
});
</script>
</body>
</html>
Output:
Similar Reads
jQuery Page Piling Plugin jQuery pagePiling.js plug-in is a rich feature available for programmers for piling more than one layout section, one over the other, and accessing each page by URL or mouse scrolling or side bullets navigation. This feature provides all type of smooth vertical, horizontal, and side navigations to t
5 min read
jQuery | Flickerplate Plugin jQuery provides Flickerplate plugin that helps our programmers to create sliders for websites that can cycle through a list of background images along with dot navigation feature and animated arrows. The plugin consists of many more libraries that are responsible for touch detections and events such
5 min read
jQuery Multiscroll Plugin jQuery provides multiscroll.js plugin which helps programmers to create split web pages along with divided multiple vertical scrolling panels.Note: Please download the jQuery multiscroll plugin to your working folder and include the required files in the head section of your code as shown below. Dow
3 min read
jQuery RowGrid Plugin jQuery provides a very simple, user-friendly and responsive rowGrid plugin that helps programmers to display images in a straight row. It is very lightweighted and supports infinite scrolling feature. Real examples of rowGrid are Google+ images or Google image search that appears in a straight row g
4 min read
jQuery Alertify Plugin jQuery framework provides alertify.js plugin that provides pre-designed customizable notification system along with interactive browser dialogs. This extensible and themeable plugin is very useful for developers providing an optimized version of alert messages with stacking up to feature. This small
5 min read
jQuery Image ProgressBars Plugin In this article, we will learn how to implement image ProgressBar feature using the jQuery Image ProgressBar plugin. Note: Please download the jQuery Image ProgressBar plugin in the working folder and include the required files in the head section of your HTML code. <link href=âprogressbar.cssâ r
2 min read
jQuery DrawSVG Plugin SVG or Scalar Vector Graphics is Extended Markup Language-based graphics supporting 2 dimensional animations of images enhancing interactiveness. The specifications of SVG are open standards by World Wide Web Consortium defined in XML text files. These files can be changed or created with any drawin
4 min read
jQuery Tagsort Plugin jQuery provides Tagsort plugin that is used for displaying tags or filter elements based on different tags in a DOM. The plugin takes data-attributes of HTML page structure and dynamically creates user-friendly tags used for filtering elements. The filtration of elements are done in many ways that a
9 min read
jQuery Logos Distort Plugin The jQuery provides LogosDistort plugin which helps in creating or animating a parallax environment for 3D scenes in the user browser. It uses full-page matrix3D perspective logos distortions for transforming base on mouse movement. You have to download the required files in the working folder so th
4 min read
jQuery Filer Plugin jQuery provides a quick jQuery Filer uploader plugin for easy implementation of uploading the files. It provides features like instant uploading of files, file append, file removal, multiple selections, drag and drop support along with other file validations.Download the required files to include it
2 min read