Accordion Widgetversion added: 1.0
Description: Convert a pair of headers and content panels into an accordion.
The markup of your accordion container needs pairs of headers and content panels:
1
2
3
4
5
6
|
|
Accordions support arbitrary markup, but each content panel must always be the next sibling after its associated header. See the header
option for information on how to use custom markup structures.
The panels can be activated programmatically by setting the active
option.
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
active
0
-
Boolean: Setting
active
tofalse
will collapse all panels. This requires thecollapsible
option to betrue
. - Integer: The zero-based index of the panel that is active (open).
animated
slide
-
Boolean: A value of
false
will disable animations. -
String: Name of easing to use with default duration. Additionally, values of
"slide"
and"bounceslide"
have built-in custom implementations.
autoHeight
true
clearStyle
false
autoHeight
option to be false
.collapsible
false
event
"click"
fillSpace
false
autoHeight
option.header
"> li > :first-child,> :not(li):even"
Selector for the header element, applied via .find()
on the main accordion element. Content panels must be the sibling immedately after their associated headers.
icons
{ "header": "ui-icon-triangle-1-e", "headerSelected": "ui-icon-triangle-1-s" }
Icons to use for headers, matching an icon defined by the jQuery UI CSS Framework. Set to false
to have no icons displayed.
- header (string, default: "ui-icon-triangle-1-e")
- headerSelected (string, default: "ui-icon-triangle-1-s")
Methods
activate( index )Returns: jQuery (plugin only)
-
indexType: IntegerThe zero-based index of the panel to activate.
Invoke the activate 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
|
|
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
|
|
resize()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the resize method:
1
|
|
widget()Returns: jQuery
jQuery
object containing the accordion.
- This method does not accept any arguments.
Invoke the widget method:
1
|
|
Events
change( event, ui )Type: accordionchange
ui.oldHeader
and ui.oldContent
will be empty jQuery objects. If the accordion is collapsing, ui.newHeader
and ui.newContent
will be empty jQuery objects.Initialize the accordion with the change callback specified:
1
2
3
|
|
Bind an event listener to the accordionchange event:
1
|
|
changestart( event, ui )Type: accordionchangestart
ui.oldHeader
and ui.oldContent
will be empty jQuery objects. If the accordion is collapsing, ui.newHeader
and ui.newContent
will be empty jQuery objects.Initialize the accordion with the changestart callback specified:
1
2
3
|
|
Bind an event listener to the accordionchangestart event:
1
|
|
create( event, ui )Type: accordioncreate
Note: The ui
object is empty but included for consistency with other events.
Initialize the accordion with the create callback specified:
1
2
3
|
|
Bind an event listener to the accordioncreate event:
1
|
|
Example:
A simple jQuery UI Accordion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
|