Easy jQuery Modal Dialog Box Plugin - dialog.js

Easy jQuery Modal Dialog Box Plugin - dialog.js
File Size: 11.3 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

dialog.js is a jQuery dialog box plugin which enables you to create beautiful and clean alert box, confirm box, contact/login form with ease.

Basic Usage:

1. Include the latest version of jQuery library from a CDN.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

2. Include the jQuery dialog.js plugin's script and stylesheet after jQuery library.

<link rel="stylesheet" href="dialog.css">
<script src="dialog.js"></script>

3. Create a button to trigger an alert box on your web page.

<button id="alert-demo">Alert</button>

4. When document ready add click behavior to the trigger button and set the custom messages for the alert box.

$(document).ready(function () {
  $("#alert-demo").click(function (event) {
    event.stopPropagation();
    $.dialog.alert("Hello World");
  });
});

5. Syntaxs.

$.dialog.open(name)
$.dialog.close(name)
$.dialog.alert(msg)
$.dialog.confirm(msg[,options])

6. Confirm options.

  • ok: "Text of OK button"
  • cancel: "Text of Cancel button"
  • option: "Text of optional button" - goes to the left of the Cancel buttonThe text of the button is returned in the onClose method if clicked.

7. Syntaxs.

.onOpen(function(element){})
.onClose(function(element){})
.onClose(function(boolean or text of optional button){}) // confirm only.
.autoClose(msecs)

7. Custom template settings.

  • path: "": Path to dialog template files. 
  • extension: ".html":  Extension of template file. This is added after the name of the dialog.
  • replace: true: If true replace the contents of the dialog each time it is displayed. If false, retain the contents of the dialog.
  • blocker: '<div class="blocker fade"></div>': Template of blocker element that contains the dialog.

Change log:

  • Add use strict

This awesome jQuery plugin is developed by tannyo. For more Advanced Usages, please check the demo page or visit the official website.