YouTip LogoYouTip

Plugins Layout Accordion

* * jQuery EasyUI Plugin](#) * * * Override the default defaults using `$.fn.accordion.defaults`. The Accordion allows you to provide multiple panels, displaying one or more panels at a time. Each panel has built-in support for expanding and collapsing. Clicking on a panel's header expands or collapses the panel's body. Panel content can be loaded via Ajax by specifying the 'href' attribute. Users can define the selected panel. If not specified, the first panel is selected by default. !(#) ## Dependencies * panel ## Usage #### Creating an Accordion Create an Accordion using markup, add the 'easyui-accordion' class to the `
` tag.

Accordion for jQuery

Accordion is a part of easyui framework for jQuery. It lets you define your accordion component on web page more easily.

content2
content3
We can change or rebuild the Accordion after modifying some properties. $('#aa').accordion({ animate:false}); #### Refreshing Accordion Panel Content Call the 'getSelected' method to get the current panel, then we can call the panel's 'refresh' method to load new content. var pp = $('#aa').accordion('getSelected'); // get the selected panel if (pp){ pp.panel('refresh','new_content.php'); // call 'refresh' method to load new content } ## Container Options | Name | Type | Description | Default Value | | --- | --- | --- | --- | | width | number | The width of the Accordion container. | auto | | height | number | The height of the Accordion container. | auto | | fit | boolean | If set to true, the Accordion container will size itself to fit its parent container. | false | | border | boolean | Defines whether to show a border. | true | | animate | boolean | Defines whether to show animation when expanding or collapsing a panel. | true | | multiple | boolean | If set to true, allows multiple panels to be expanded at the same time. This property is available since version 1.3.5. | false | | selected | number | The index of the initially selected panel. This property is available since version 1.3.5. | 0 | ## Panel Options The panel options of the Accordion are inherited from the panel, the following are additional properties: | Name | Type | Description | Default Value | | --- | --- | --- | --- | | selected | boolean | If set to true, the panel is expanded. | false | | collapsible | boolean | Defines whether to show the collapsible button. If set to false, the panel cannot be expanded/collapsed by clicking. | true | ## Events | Name | Parameters | Description | | --- | --- | --- | | onSelect | title,index | Fires when a panel is selected. | | onUnselect | title,index | Fires when a panel is unselected. This event is available since version 1.3.5. | | onAdd | title,index | Fires when a new panel is added. | | onBeforeRemove | title,index | Fires before a panel is removed. Return false to cancel the remove action. | | onRemove | title,index | Fires when a panel is removed. | ## Methods | Name | Parameters | Description | | --- | --- | --- | | options | none | Returns the options of the accordion. | | panels | none | Gets all the panels. | | resize | none | Resizes the accordion. | | getSelected | none | Gets the first selected panel. | | getSelections | none | Gets all selected panels. This method is available since version 1.3.5. | | getPanel | which | Gets the specified panel. The 'which' parameter can be the panel's title or index. | | getPanelIndex | panel | Gets the index of the specified panel. This method is available since version 1.3. The following example shows how to get the selected panel's index.

var p = $('#aa').accordion('getSelected');
if (p){
var index = $('#aa').accordion('getPanelIndex', p);
alert(index);
} | | select | which | Selects the specified panel. The 'which' parameter can be the panel's title or index. | | unselect | which | Unselects the specified panel. The 'which' parameter can be the panel's title or index. This method is available since version 1.3.5. | | add | options | Adds a new panel. By default, the newly added panel is selected. To add a new panel that is not selected, pass the 'selected' property and set it to false.

Code example:
$('#aa').accordion('add', {
title: 'New Title',
content: 'New Content',
selected: false
}); | | remove | which | Removes the specified panel. The 'which' parameter can be the panel's title or index. | * * jQuery EasyUI Plugin](#)
← Plugins Layout LayoutJava Basic Datatypes β†’