Dialog Demo

DEMO

Alert

Confirm

Login


(正确的用户名是jinjiang,密码是maxthon)

Step by Step

Source Code

Source code (based on jquery and used in requirejs)

API

dialog.alert(text)

Just a alert.

text
Alert text description.

dialog.confirm(text, doYes, doNo)

Just a confirm.

text
Confirm text description.
doYes()
Run when user choose yes.
doNo()
Run when user choose no.

dialog.show(title, contentHtml, config)

Show a dialog with a centain title, content, and config.

title
Dialog title text.
contentHtml
Dialog content html code.
config
Available keys are: oncreate, onclose, css.
oncreate(dialogObj)
Run when the dialog object created but not shown.
afterCreate(dialogObj)
Run when the dialog object shown.
onclose()
Run when close the dialog.
css
Custom CSS style for the dialog.

dialog.update(title, contentHtml, config)

Show a dialog with a centain title, content, and config.

title
Dialog title text.
contentHtml
Dialog content html code.
config
Available keys are: onclose, css, beforeUpdate, afterUpdate.
beforeUpdate(dialogObj)
Run before the dialog object updated.
afterUpdate(dialogObj)
Run after the dialog object updated.

dialog.hide()

Fire onclose event first. If no prevent, then close the dialog.

dialog.forceHide()

Hide dialog without any confirm.

dialog.setTemplate()

Set the dialog html template.

dialog.resetTemplate()

Reset the dialog html template to default.

dialog.TEMPLATE

The default dialog html template.

dialogObj.element

The jQuery element object for the dialogObj.

dialogObj.config

The config for the dialogObj.

dialogObj.setTitle(text)

Set the title of the dialog.

dialogObj.setContent(contentHtml)

Set the content html of the dialog.