Dialog Widgetversion added: 1.0
Description: Open content in an interactive overlay.
A dialog is a floating window that contains a title bar and a content area. The dialog window can be moved, resized and closed with the 'x' icon by default.
If the content length exceeds the maximum height, a scrollbar will automatically appear.
A bottom button bar and semi-transparent modal overlay layer are common options that can be added.
Additional Notes:
- This widget requires some functional CSS, otherwise it won't work. If you build a custom theme, use the widget's specific CSS file as a starting point.
Options
autoOpen
true
true
, the dialog will automatically open upon initialization. If false
, the dialog will stay hidden until the open()
method is called.closeOnEscape
true
closeText
"close"
dialogClass
""
draggable
true
true
, the dialog will be draggable by the title bar. Requires the jQuery UI Draggable wiget to be included.height
"auto"
- Number: The height in pixels.
-
String: The only supported string value is
"auto"
which will allow the dialog height to adjust based on its content.
hide
null
- Number: The dialog will fade out while animating the height and width for the specified duration.
- String: The dialog will be hidden using the specified jQuery UI effect. See the list of effects for possible values.
-
Object: If the value is an object, then
effect
,duration
, andeasing
properties may be provided. Theeffect
property must be the name of a jQuery UI effect. When using a jQuery UI effect that supports additional settings, you may include those settings in the object and they will be passed to the effect. Ifduration
oreasing
is omitted, then the default values will be used.
maxHeight
false
maxWidth
false
minHeight
150
modal
false
true
, the dialog will have modal behavior; other items on the page will be disabled, i.e., cannot be interacted with. Modal dialogs create an overlay below the dialog but above other page elements.position
{ my: "center", at: "center", of: window }
-
Object: Identifies the position of the dialog when opened. The
of
option defaults to the window, but you can specify another element to position against. You can refer to the jQuery UI Position utility for more details about the various options. -
String: A string representing the position within the viewport. Possible values:
"center"
,"left"
,"right"
,"top"
,"botom"
. - Array: An array containing an x, y coordinate pair in pixel offset from the top left corner of the viewport or the name of a possible string value.
resizable
true
true
, the dialog will be resizable. Requires the jQuery UI Resizable widget to be included.show
null
- Number: The dialog will fade in while animating the height and width for the specified duration.
- String: The dialog will be shown using the specified jQuery UI effect. See the list of effects for possible values.
-
Object: If the value is an object, then
effect
,duration
, andeasing
properties may be provided. Theeffect
property must be the name of a jQuery UI effect. When using a jQuery UI effect that supports additional settings, you may include those settings in the object and they will be passed to the effect. Ifduration
oreasing
is omitted, then the default values will be used.
stack
true
title
""
title
attribute on the dialog source element.Methods
close()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the close method:
1
|
|
destroy()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the destroy method:
1
|
|
disable()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the disable method:
1
|
|
enable()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the enable method:
1
|
|
isOpen()Returns: Boolean
- This method does not accept any arguments.
Invoke the isOpen method:
1
|
|
moveToTop()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the moveToTop method:
1
|
|
open()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the open method:
1
|
|
option( optionName )Returns: Object
optionName
.-
optionNameType: StringThe name of the option to get.
Invoke the method:
1
|
|
option()Returns: PlainObject
- This signature does not accept any arguments.
Invoke the method:
1
|
|
option( optionName, value )Returns: jQuery (plugin only)
optionName
.-
optionNameType: StringThe name of the option to set.
-
valueType: ObjectA value to set for the option.
Invoke the method:
1
|
|
option( options )Returns: jQuery (plugin only)
-
optionsType: ObjectA map of option-value pairs to set.
Invoke the method:
1
|
|
widget()Returns: jQuery
jQuery
object containing the generated wrapper.
- This method does not accept any arguments.
Invoke the widget method:
1
|
|
Events
beforeClose( event, ui )Type: dialogbeforeclose
Note: The ui
object is empty but included for consistency with other events.
Initialize the dialog with the beforeClose callback specified:
1
2
3
|
|
Bind an event listener to the dialogbeforeclose event:
1
|
|
close( event, ui )Type: dialogclose
Note: The ui
object is empty but included for consistency with other events.
Initialize the dialog with the close callback specified:
1
2
3
|
|
Bind an event listener to the dialogclose event:
1
|
|
create( event, ui )Type: dialogcreate
Note: The ui
object is empty but included for consistency with other events.
Initialize the dialog with the create callback specified:
1
2
3
|
|
Bind an event listener to the dialogcreate event:
1
|
|
drag( event, ui )Type: dialogdrag
Initialize the dialog with the drag callback specified:
1
2
3
|
|
Bind an event listener to the dialogdrag event:
1
|
|
dragStart( event, ui )Type: dialogdragstart
Initialize the dialog with the dragStart callback specified:
1
2
3
|
|
Bind an event listener to the dialogdragstart event:
1
|
|
dragStop( event, ui )Type: dialogdragstop
Initialize the dialog with the dragStop callback specified:
1
2
3
|
|
Bind an event listener to the dialogdragstop event:
1
|
|
focus( event, ui )Type: dialogfocus
Note: The ui
object is empty but included for consistency with other events.
Initialize the dialog with the focus callback specified:
1
2
3
|
|
Bind an event listener to the dialogfocus event:
1
|
|
open( event, ui )Type: dialogopen
Note: The ui
object is empty but included for consistency with other events.
Initialize the dialog with the open callback specified:
1
2
3
|
|
Bind an event listener to the dialogopen event:
1
|
|
resize( event, ui )Type: dialogresize
Initialize the dialog with the resize callback specified:
1
2
3
|
|
Bind an event listener to the dialogresize event:
1
|
|
resizeStart( event, ui )Type: dialogresizestart
Initialize the dialog with the resizeStart callback specified:
1
2
3
|
|
Bind an event listener to the dialogresizestart event:
1
|
|
resizeStop( event, ui )Type: dialogresizestop
Initialize the dialog with the resizeStop callback specified:
1
2
3
|
|
Bind an event listener to the dialogresizestop event:
1
|
|
Example:
A simple jQuery UI Dialog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
|