YUI Library Home

YUI Library Examples: Container Family: SimpleDialog Quickstart Example

Container Family: SimpleDialog Quickstart Example

Use the SimpleDialog Control when you want to solicit very simple (usually binary) information from your users — ok/cancel, yes/no are the classic examples of this sort of interaction. Use the button below to show a SimpleDialog instance; if you click "yes", that choice will be echoed back to you by script.

Setting up the SimpleDialog

The SimpleDialog Control is an extension of Dialog that reproduces the behavior of a simple dialog box (but without using an actual browser popup window); its primary use is to elicit binary decisions from the user (yes/no, okay/cancel, etc.). SimpleDialog makes it easy to implement this kind of interaction. In this tutorial, we will create a SimpleDialog with "Yes"/"No" choices, and display an alert if the user clicks "Yes".

SimpleDialog defines two new properties:

  1. icon: defines which of six standard icons will be displayed in the SimpleDialog;
  2. text: used to specify a small amount of text to display in the SimpleDialog.

The "buttons" property is inherited from Dialog, and uses the same familiar array-of-object literals syntax as demonstrated in the following constructor:

1// Instantiate the Dialog 
2YAHOO.example.container.simpledialog1 =  
3    new YAHOO.widget.SimpleDialog("simpledialog1",  
4             { width: "300px"
5               fixedcenter: true
6               visible: false
7               draggable: false
8               close: true
9               text: "Do you want to continue?"
10               icon: YAHOO.widget.SimpleDialog.ICON_HELP, 
11               constraintoviewport: true
12               buttons: [ { text:"Yes", handler:handleYes, isDefault:true }, 
13                          { text:"No",  handler:handleNo } ] 
14             } ); 
view plain | print | ?

Next, we'll define the handlers for our buttons. Clicking "Yes" will cause an alert to be displayed, whereas the "No" button will simply dismiss the SimpleDialog:

1// Define various event handlers for Dialog 
2var handleYes = function() { 
3    alert("You clicked yes!"); 
4    this.hide(); 
5}; 
6 
7var handleNo = function() { 
8    this.hide(); 
9}; 
view plain | print | ?

Configuration for This Example

You can load the necessary JavaScript and CSS for this example from Yahoo's servers. Click here to load the YUI Dependency Configurator with all of this example's dependencies preconfigured.

YUI Logger Output:

Logger Console

INFO 1818ms (+5) 3:44:49 AM:

Config

Firing Config event: iframe=false

INFO 1813ms (+0) 3:44:49 AM:

Config

Config event queue: iframe=false,

INFO 1813ms (+0) 3:44:49 AM:

Config

queueProperty: iframe=undefined

INFO 1813ms (+0) 3:44:49 AM:

Config

setProperty: xy=39,350

INFO 1813ms (+0) 3:44:49 AM:

Config

setProperty: xy=39,350

INFO 1813ms (+0) 3:44:49 AM:

Config

setProperty: y=350

INFO 1813ms (+0) 3:44:49 AM:

Config

setProperty: x=39

INFO 1813ms (+0) 3:44:49 AM:

Config

setProperty: y=350

INFO 1813ms (+0) 3:44:49 AM:

Config

setProperty: x=39

INFO 1813ms (+0) 3:44:49 AM:

Config

Firing Config event: y=350

INFO 1813ms (+0) 3:44:49 AM:

Config

Config event queue: y=350, iframe=false,

INFO 1813ms (+0) 3:44:49 AM:

Config

queueProperty: iframe=undefined

INFO 1813ms (+1) 3:44:49 AM:

Config

setProperty: xy=39,350

INFO 1812ms (+0) 3:44:49 AM:

Config

setProperty: xy=39,350

INFO 1812ms (+1) 3:44:49 AM:

Config

setProperty: y=350

INFO 1811ms (+1) 3:44:49 AM:

Config

setProperty: x=39

INFO 1810ms (+0) 3:44:49 AM:

Config

setProperty: y=350

INFO 1810ms (+0) 3:44:49 AM:

Config

setProperty: x=39

INFO 1810ms (+0) 3:44:49 AM:

Config

Firing Config event: x=39

INFO 1810ms (+0) 3:44:49 AM:

Config

Firing Config event: icon=hlpicon

INFO 1810ms (+0) 3:44:49 AM:

Config

Config event queue: icon=hlpicon, x=39, y=350, iframe=false,

INFO 1810ms (+0) 3:44:49 AM:

Config

queueProperty: iframe=undefined

IFRA 1810ms (+0) 3:44:49 AM:

global

xy: 39,350

INFO 1810ms (+0) 3:44:49 AM:

Config

setProperty: xy=39,350

INFO 1810ms (+0) 3:44:49 AM:

Config

setProperty: y=350

INFO 1810ms (+1) 3:44:49 AM:

Config

setProperty: x=39

INFO 1809ms (+0) 3:44:49 AM:

Config

Config event queue: icon=hlpicon, x=39, y=350, iframe=false,

INFO 1809ms (+0) 3:44:49 AM:

Config

queueProperty: y=350

INFO 1809ms (+0) 3:44:49 AM:

Config

setProperty: y=350

INFO 1809ms (+0) 3:44:49 AM:

Config

Config event queue: icon=hlpicon, x=39, iframe=false,

INFO 1809ms (+0) 3:44:49 AM:

Config

queueProperty: x=39

INFO 1809ms (+0) 3:44:49 AM:

Config

setProperty: x=39

INFO 1809ms (+0) 3:44:49 AM:

Config

Firing Config event: xy=39,350

INFO 1809ms (+2) 3:44:49 AM:

Config

Firing Config event: visible=false

INFO 1807ms (+1) 3:44:49 AM:

Config

Firing Config event: buttons=[object Object],[object Object]

INFO 1806ms (+0) 3:44:49 AM:

Config

Firing Config event: constraintoviewport=true

INFO 1806ms (+0) 3:44:49 AM:

Config

Config event queue: constraintoviewport=true, buttons=[object Object],[object Object], visible=false, xy=39,350, iframe=false, icon=hlpicon,

INFO 1806ms (+1) 3:44:49 AM:

Config

queueProperty: icon=undefined

INFO 1805ms (+0) 3:44:49 AM:

Config

Firing Config event: text=Do you want to continue?

INFO 1805ms (+0) 3:44:49 AM:

Config

Firing Config event: close=true

INFO 1805ms (+0) 3:44:49 AM:

Config

Firing Config event: draggable=false

INFO 1805ms (+0) 3:44:49 AM:

Config

Config event queue: draggable=false, close=true, text=Do you want to continue?, icon=hlpicon, constraintoviewport=true, buttons=[object Object],[object Object], visible=false, xy=39,350, iframe=false,

INFO 1805ms (+0) 3:44:49 AM:

Config

queueProperty: iframe=undefined

INFO 1805ms (+0) 3:44:49 AM:

Config

Config event queue: draggable=false, close=true, text=Do you want to continue?, icon=hlpicon, constraintoviewport=true, buttons=[object Object],[object Object], visible=false, xy=39,350, iframe=false,

INFO 1805ms (+0) 3:44:49 AM:

Config

queueProperty: xy=39,350

INFO 1805ms (+8) 3:44:49 AM:

Config

setProperty: xy=39,350

INFO 1797ms (+0) 3:44:49 AM:

Config

Firing Config event: fixedcenter=true

INFO 1797ms (+0) 3:44:49 AM:

Config

Config event queue: fixedcenter=true, draggable=false, close=true, text=Do you want to continue?, icon=hlpicon, constraintoviewport=true, buttons=[object Object],[object Object], visible=false, iframe=false,

INFO 1797ms (+1) 3:44:49 AM:

Config

queueProperty: iframe=undefined

INFO 1796ms (+0) 3:44:49 AM:

Config

Firing Config event: width=300px

INFO 1796ms (+0) 3:44:49 AM:

Config

Firing Config event: postmethod=manual

INFO 1796ms (+0) 3:44:49 AM:

Config

Firing Config event: hideaftersubmit=true

INFO 1796ms (+0) 3:44:49 AM:

Config

Firing Config event: postdata=null

INFO 1796ms (+0) 3:44:49 AM:

Config

setProperty: strings=[object Object]

INFO 1796ms (+0) 3:44:49 AM:

Config

Firing Config event: strings=[object Object]

INFO 1796ms (+0) 3:44:49 AM:

Config

setProperty: zindex=0

INFO 1796ms (+0) 3:44:49 AM:

Config

Firing Config event: zindex=null

INFO 1796ms (+1) 3:44:49 AM:

Config

Firing Config event: modal=false

INFO 1795ms (+0) 3:44:49 AM:

Config

Firing Config event: underlay=shadow

INFO 1795ms (+0) 3:44:49 AM:

Config

Firing Config event: dragonly=false

INFO 1795ms (+0) 3:44:49 AM:

Config

Firing Config event: preventcontextoverlap=false

INFO 1795ms (+0) 3:44:49 AM:

Config

setProperty: autofillheight=body

INFO 1795ms (+0) 3:44:49 AM:

Config

Firing Config event: autofillheight=body

INFO 1795ms (+16) 3:44:49 AM:

Config

Firing Config event: appendtodocumentbody=false

INFO 1779ms (+0) 3:44:49 AM:

Config

Firing Config event: monitorresize=true

INFO 1779ms (+1) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, autofillheight=body, preventcontextoverlap=false, dragonly=false, underlay=shadow, modal=false, zindex=null, strings=[object Object], postdata=null, hideaftersubmit=true, postmethod=manual, width=300px, fixedcenter=true, draggable=false, close=true, text=Do you want to continue?, icon=hlpicon, constraintoviewport=true, iframe=false, buttons=[object Object],[object Object], visible=false,

INFO 1778ms (+0) 3:44:49 AM:

Config

queueProperty: buttons=[object Object],[object Object]

INFO 1778ms (+0) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, autofillheight=body, preventcontextoverlap=false, dragonly=false, underlay=shadow, modal=false, zindex=null, strings=[object Object], postdata=null, hideaftersubmit=true, buttons=none, postmethod=manual, width=300px, fixedcenter=true, draggable=false, close=true, visible=false, text=Do you want to continue?, icon=hlpicon, constraintoviewport=true, iframe=false,

INFO 1778ms (+0) 3:44:49 AM:

Config

queueProperty: constraintoviewport=true

INFO 1778ms (+0) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, autofillheight=body, preventcontextoverlap=false, constraintoviewport=false, dragonly=false, underlay=shadow, modal=false, zindex=null, strings=[object Object], postdata=null, hideaftersubmit=true, buttons=none, postmethod=manual, width=300px, fixedcenter=true, iframe=false, draggable=false, close=true, visible=false, text=Do you want to continue?, icon=hlpicon,

INFO 1778ms (+0) 3:44:49 AM:

Config

queueProperty: icon=hlpicon

INFO 1778ms (+0) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, autofillheight=body, preventcontextoverlap=false, constraintoviewport=false, dragonly=false, underlay=shadow, modal=false, zindex=null, strings=[object Object], postdata=null, hideaftersubmit=true, buttons=none, postmethod=manual, width=300px, fixedcenter=true, iframe=false, draggable=false, close=true, visible=false, text=Do you want to continue?,

INFO 1778ms (+0) 3:44:49 AM:

Config

queueProperty: text=Do you want to continue?

INFO 1778ms (+0) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, autofillheight=body, preventcontextoverlap=false, constraintoviewport=false, dragonly=false, underlay=shadow, modal=false, zindex=null, strings=[object Object], postdata=null, hideaftersubmit=true, buttons=none, postmethod=manual, width=300px, fixedcenter=true, iframe=false, draggable=false, close=true, visible=false,

INFO 1778ms (+0) 3:44:49 AM:

Config

queueProperty: close=true

INFO 1778ms (+0) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, autofillheight=body, preventcontextoverlap=false, constraintoviewport=false, dragonly=false, underlay=shadow, modal=false, zindex=null, strings=[object Object], close=true, postdata=null, hideaftersubmit=true, buttons=none, postmethod=manual, width=300px, fixedcenter=true, iframe=false, draggable=false, visible=false,

INFO 1778ms (+0) 3:44:49 AM:

Config

queueProperty: draggable=false

INFO 1778ms (+0) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, autofillheight=body, preventcontextoverlap=false, constraintoviewport=false, dragonly=false, draggable=false, underlay=shadow, modal=false, zindex=null, strings=[object Object], close=true, postdata=null, hideaftersubmit=true, buttons=none, postmethod=manual, width=300px, fixedcenter=true, iframe=false, visible=false,

INFO 1778ms (+0) 3:44:49 AM:

Config

queueProperty: visible=false

INFO 1778ms (+0) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, autofillheight=body, preventcontextoverlap=false, constraintoviewport=false, dragonly=false, draggable=false, underlay=shadow, modal=false, zindex=null, strings=[object Object], close=true, postdata=null, hideaftersubmit=true, buttons=none, postmethod=manual, width=300px, fixedcenter=true, iframe=false, visible=true,

INFO 1778ms (+0) 3:44:49 AM:

Config

queueProperty: fixedcenter=true

INFO 1778ms (+0) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, autofillheight=body, preventcontextoverlap=false, constraintoviewport=false, dragonly=false, draggable=false, underlay=shadow, modal=false, zindex=null, strings=[object Object], close=true, postdata=null, hideaftersubmit=true, buttons=none, visible=true, postmethod=manual, width=300px, fixedcenter=false, iframe=false,

INFO 1778ms (+0) 3:44:49 AM:

Config

queueProperty: width=300px

INFO 1778ms (+0) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, autofillheight=body, iframe=false, preventcontextoverlap=false, constraintoviewport=false, dragonly=false, draggable=false, underlay=shadow, modal=false, zindex=null, strings=[object Object], close=true, postdata=null, hideaftersubmit=true, buttons=none, visible=true, postmethod=manual,

INFO 1778ms (+20) 3:44:49 AM:

Config

queueProperty: postmethod=manual

INFO 1758ms (+0) 3:44:49 AM:

Config

Firing Config event: visible=false

INFO 1758ms (+0) 3:44:49 AM:

Config

setProperty: visible=false

INFO 1758ms (+0) 3:44:49 AM:

Config

setProperty: text=

INFO 1758ms (+0) 3:44:49 AM:

Config

Added property: text

INFO 1758ms (+0) 3:44:49 AM:

Config

setProperty: icon=none

INFO 1758ms (+0) 3:44:49 AM:

Config

Added property: icon

INFO 1758ms (+0) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, autofillheight=body, iframe=false, preventcontextoverlap=false, constraintoviewport=false, dragonly=false, draggable=false, underlay=shadow, modal=false, zindex=null, strings=[object Object], close=true, postmethod=async, postdata=null, hideaftersubmit=true, buttons=none, visible=true,

INFO 1758ms (+0) 3:44:49 AM:

Config

queueProperty: buttons=none

INFO 1758ms (+0) 3:44:49 AM:

Config

setProperty: buttons=none

INFO 1758ms (+0) 3:44:49 AM:

Config

Added property: buttons

INFO 1758ms (+0) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, autofillheight=body, iframe=false, preventcontextoverlap=false, constraintoviewport=false, dragonly=false, draggable=false, underlay=shadow, modal=false, visible=true, zindex=null, strings=[object Object], close=true, postmethod=async, postdata=null, hideaftersubmit=true,

INFO 1758ms (+0) 3:44:49 AM:

Config

queueProperty: hideaftersubmit=true

INFO 1758ms (+0) 3:44:49 AM:

Config

setProperty: hideaftersubmit=true

INFO 1758ms (+0) 3:44:49 AM:

Config

Added property: hideaftersubmit

INFO 1758ms (+1758) 3:44:49 AM:

Config

Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, autofillheight=body, iframe=false, preventcontextoverlap=false, constraintoviewport=false, dragonly=false, draggable=false, underlay=shadow, modal=false, visible=true, zindex=null, strings=[object Object], close=true, postmethod=async, postdata=null,

INFO 0ms (+0) 3:44:47 AM:

global

Logger initialized

Note: You are viewing this example in debug mode with logging enabled. This can significantly slow performance.

Reload with logging
and debugging disabled.

Container Family Examples:

More Container Family Resources:

Copyright © 2009 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings