前基本用法如下:
[php]
widget('zii.widgets.jui.cjuitabs', array(
'tabs'=>array(
'static tab'=>'static content',
'render tab'=>$this->renderpartial('pages/_content1',null,true),
'ajax tab'=>array('ajax'=>array('ajaxcontent','view'=>'_content2')),
),
'options'=>array(
'collapsible'=>true,
'selected'=>1,
),
'htmloptions'=>array(
'style'=>'width:500px;'
),
)); ?>
widget('zii.widgets.jui.cjuitabs', array(
'tabs'=>array(
'static tab'=>'static content',
'render tab'=>$this->renderpartial('pages/_content1',null,true),
'ajax tab'=>array('ajax'=>array('ajaxcontent','view'=>'_content2')),
),
'options'=>array(
'collapsible'=>true,
'selected'=>1,
),
'htmloptions'=>array(
'style'=>'width:500px;'
),
)); ?>
显示了三个页面不同内容显示方法,static tab显示一个静态内容,render tab使用partial渲染一个页面,而ajax tab则通过ajax显示一个页面,注意后面两个需要在sitecontroller中定义actions 如下:
[php]
public function actions()
{
return array(
'page'=>array(
'class'=>'cviewaction',
),
// ajaxcontent action renders
//static pages stored under 'protected/views/site/pages'
// they can be accessed via:
//index.php?r=site/ajaxcontent&view=filename
'ajaxcontent'=>array(
'class'=>'application.controllers.ajaxviewaction',
),
);
}
public function actions()
{
return array(
'page'=>array(
'class'=>'cviewaction',
),
// ajaxcontent action renders
//static pages stored under 'protected/views/site/pages'
// they can be accessed via:
//index.php?r=site/ajaxcontent&view=filename
'ajaxcontent'=>array(
'class'=>'application.controllers.ajaxviewaction',
),
);
}
其中ajaxviewaction为一自定义viewaction,为cviewaction的子类,可以显示静态页面,其定义如下:
[php]
class ajaxviewaction extends cviewaction
{
private $_viewpath;
public function run()
{
if(yii::app()->request->isajaxrequest)
{
$this->resolveview($this->getrequestedview());
$controller=$this->getcontroller();
$controller->renderpartial($this->view, null, false, true);
}
else
throw new chttpexception(400,'invalid request.
please do not repeat this request again.');
}
}
class ajaxviewaction extends cviewaction
{
private $_viewpath;
public function run()
{
if(yii::app()->request->isajaxrequest)
{
$this->resolveview($this->getrequestedview());
$controller=$this->getcontroller();
$controller->renderpartial($this->view, null, false, true);
}
else
throw new chttpexception(400,'invalid request.
please do not repeat this request again.');
}
}
显示结果如下:
http://www.bkjia.com/phpjc/477828.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/477828.htmltecharticle前基本用法如下: [php] ?php $this-widget(zii.widgets.jui.cjuitabs, array( tabs=array( static tab=static content, render tab=$this-renderpartial(pages/_content1,null,true), a...