Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery EasyUI Layout Plugin - Accordion

jQuery EasyUI Layout Plugin - Accordion


jQuery EasyUI Plugins jQuery EasyUI Plugins


Override the default defaults via $.fn.accordion.defaults.

The accordion lets you provide multiple panels and display one or more of them at a time. Each panel has built-in support for expanding and collapsing. Clicking a panel header expands or collapses the panel body. Panel content can be loaded via AJAX by specifying the 'href' property. Users can define which panel is selected. If not specified, the first panel is selected by default.

Depends on

Usage

Creating an Accordion

Create an accordion from markup by adding the 'easyui-accordion' class to

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 certain 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'); // 获取选中的面板(panel)

if (pp){

    pp.panel('refresh','new_content.php'); // 调用 'refresh' 方法加载新内容

}

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 When set to true, the accordion container is sized to fit its parent container. false
border boolean Defines whether to show a border. true
animate boolean Defines whether to show animation when a panel is expanded or collapsed. true
multiple boolean When set to true, multiple panels can be expanded at the same time. Available since version 1.3.5. false
selected number The index of the initially selected panel. Available since version 1.3.5. 0

Panel Options

The accordion's panel options inherit from panel; the following are additional properties:

Name Type Description Default value
selected boolean Expands the panel when set to true. false
collapsible boolean Defines whether to show the collapse button. If set to false, the panel cannot be expanded/collapsed by clicking. true

Events

Name Parameters Description
onSelect title,index Triggered when a panel is selected.
onUnselect title,index Triggered when a panel is unselected. Available since version 1.3.5.
onAdd title,index Triggered when a new panel is added.
onBeforeRemove title,index Triggered before a panel is removed; returning false cancels the removal.
onRemove title,index Triggered when a panel is removed.

Method

Name Parameters Description
options none Returns the accordion options.
panels none Gets all panels.
resize none Resizes the accordion.
getSelected none Gets the first selected panel.
getSelections none Gets all selected panels. 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. Available since version 1.3.
 下面的实例显示如何获取选中的面板(panel)索引。     

var p = $('#aa').accordion('getSelected'); if (p){ var index = $('#aa').accordion('getPanelIndex', p); alert(index); }| onSelect | event | select | which | Select the specified panel (panel). The 'which' parameter can be the title (title) or index (index) of the panel (panel).| onSelect | event | unselect | which | Deselect the specified panel (panel). The 'which' parameter can be the title (title) or index (index) of the panel (panel). This method is available since version 1.3.5.| onSelect | event | add | options | Add a new panel (panel). By default, the newly added panel (panel) will be selected. To add a new panel (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

});

| onSelect | event | remove | which | Remove the specified panel (panel). The 'which' parameter can be the title (title) or index (index) of the panel (panel). |


jQuery EasyUI Plugins jQuery EasyUI Plugins