Tabs Widgetversion added: 1.0
Description: A single content area with multiple panels, each associated with a header in a list.
Tabs are generally used to break content into multiple sections that can be swapped to save space, much like an accordion.
The content for each tab panel can be defined in-page or can be loaded via Ajax; both are handled automatically based on the href
of the anchor associated with the tab. By default tabs are activated on click, but the events can be changed to hover via the event
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
ajaxOptions
null
jQuery.ajax()
).cache
false
cache: false
flag in the ajaxOptions
option.disabled
false
- Boolean: Enable or disable all tabs.
-
Array: An array containing the zero-based indexes of the tabs that should be disabled, e.g.,
[ 0, 2 ]
would disable the first and third tab.
event
"click"
"mouseover"
.fx
null
-
Object: Key/value pairs of properties to animate and optional duration, e.g.,
{ height: "toggle", duration: 200 }
. -
Array: Animation settings in the form
[ hideSettings, showSettings ]
.
idPrefix
"ui-tabs-"
"ui-tabs-54"
.panelTemplate
"<div></div>"
add()
method or when creating a panel for a remote tab on the fly.selected
0
selected
to -1
will collapse all panels. This requires the collapsible
option to be true
.
spinner
"<em>Loading…</em>"
Methods
abort()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the abort method:
1
|
|
add( url, label [, index ] )Returns: jQuery (plugin only)
-
urlType: StringThe URL of the tab to add.
-
labelType: StringThe name of the tab to add.
-
indexType: NumberWhere to add the new tab (zero-based). If omitted, the new tab will be added as the last tab.
Invoke the add 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 signature does not accept any arguments.
Invoke the method:
1
|
|
disable( index )Returns: jQuery (plugin only)
disabled
option: $( "#tabs" ).tabs( "option", "disabled", [ 1, 2, 3 ] )
.
-
indexWhich tab to disable.
Invoke the method:
1
|
|
enable()Returns: jQuery (plugin only)
- This signature does not accept any arguments.
Invoke the method:
1
|
|
enable( index )Returns: jQuery (plugin only)
$( "#example" ).tabs( "option", "disabled", [] );
.-
indexWhich tab to enable.
Invoke the method:
1
|
|
length()Returns: Integer
- This method does not accept any arguments.
Invoke the length method:
1
|
|
load( index )Returns: jQuery (plugin only)
-
indexWhich tab to load.
Invoke the load 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
|
|
remove( index )Returns: jQuery (plugin only)
-
indexWhich tab to remove.
Invoke the remove method:
1
|
|
rotate( duration [, continuing ] )Returns: jQuery (plugin only)
-
durationType: NumberThe duration in milliseconds for each tab to be visible before rotating to the next tab.
-
continuing (default:
false
)Type: BooleanWhether or not to continue the rotation after a tab has been selected by a user.
Invoke the rotate method:
1
|
|
select( index )Returns: jQuery (plugin only)
-
indexWhich tab to select.
Invoke the select method:
1
|
|
url( index, url )Returns: jQuery (plugin only)
-
indexType: IntegerThe zero-based index of the tab to update.
-
urlType: StringThe URL to set for the tab.
Invoke the url method:
1
|
|
widget()Returns: jQuery
jQuery
object containing the tabs container.
- This method does not accept any arguments.
Invoke the widget method:
1
|
|
Events
add( event, ui )Type: tabsadd
Initialize the tabs with the add callback specified:
1
2
3
|
|
Bind an event listener to the tabsadd event:
1
|
|
create( event, ui )Type: tabscreate
Note: The ui
object is empty but included for consistency with other events.
Initialize the tabs with the create callback specified:
1
2
3
|
|
Bind an event listener to the tabscreate event:
1
|
|
disable( event, ui )Type: tabsdisable
Initialize the tabs with the disable callback specified:
1
2
3
|
|
Bind an event listener to the tabsdisable event:
1
|
|
enable( event, ui )Type: tabsenable
Initialize the tabs with the enable callback specified:
1
2
3
|
|
Bind an event listener to the tabsenable event:
1
|
|
load( event, ui )Type: tabsload
Initialize the tabs with the load callback specified:
1
2
3
|
|
Bind an event listener to the tabsload event:
1
|
|
remove( event, ui )Type: tabsremove
Initialize the tabs with the remove callback specified:
1
2
3
|
|
Bind an event listener to the tabsremove event:
1
|
|
select( event, ui )Type: tabsselect
Initialize the tabs with the select callback specified:
1
2
3
|
|
Bind an event listener to the tabsselect event:
1
|
|
show( event, ui )Type: tabsshow
Initialize the tabs with the show callback specified:
1
2
3
|
|
Bind an event listener to the tabsshow event:
1
|
|
Example:
A simple jQuery UI Tabs
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
|
|