jQuery Modal對話框插件:dialog.js
dialog.js 是一個jQuery對話框插件,能夠讓你創建漂亮和簡潔的警告框,確認框,聯系/登錄表單。
基本用法:
1. Include the latest version of jQuery library from a CDN.
<script src="http://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.
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!