0

我正在使用以下 YII 小部件代码

$this->widget('zii.widgets.jui.CJuiAccordion',array(
'panels'=>array(
    'panel 1'=>'content for panel 1',
    'panel 2'=>'content for panel 2',
    // panel 3 contains the content rendered by a partial view
    //'panel 3'=>$this->renderPartial('_partial',null,true),
),
// additional javascript options for the accordion plugin
'options'=>array(
    'animated'=>'bounceslide',
),
));

我想点击面板 2 并在页面加载时显示数据,我该怎么办?

4

1 回答 1

3

您可以通过选项active参数传递打开的面板的从零开始的索引,如下所述:http: //api.jqueryui.com/accordion/#option-active。在您的情况下,代码将是:

$this->widget('zii.widgets.jui.CJuiAccordion',array(
    'panels' => array(
        'panel 1' => 'content for panel 1',
        'panel 2' => 'content for panel 2',
        // panel 3 contains the content rendered by a partial view
        //'panel 3' => $this->renderPartial('_partial',null,true),
    ),
    // additional javascript options for the accordion plugin
    'options' => array(
        'animated' => 'bounceslide',
        'active' => 1,
    ),
));
于 2013-05-22T07:44:02.583 回答