我在CJuiDialog中使用iframe,iframe包含renderPartial来渲染一些字段。在按钮中单击即可打开对话框但对话框为空!不显示通过renderPartial
呈现的字段我的观看代码:
<?php
$this->beginWidget('zii.Widgets.jui.CJuiDialog',array(
'id'=>'RefList-New',
'options'=>array(
'title'=>'Ref List Value',
'autoOpen'=>false,
'modal'=>true,
'width'=>550,
'height'=>350,
'close'=>'js:function(){
}',
),
));
?>
<iframe id="cru-frame-RefNew" width="100%" height="100%" frameBorder="0" scrolling="no" >
<?php $this->renderPartial('reflist_New', array('model'=>$model,'base'=>$base)); ?>
</iframe>
<?php $this->endWidget();?>
<?php echo CHtml::imageButton(Yii::app()->request->baseUrl.'/images/new.jpg',array('id'=>'reflist-button','style'=>'display:inline-block'));?>
Yii脚本部分:
<?php
Yii::app()->clientScript->registerScript('uploaddfsfd', "
$('#reflist-button').click(function() {
$('#RefList-New').dialog('open'); return false;
});
");
?>
当我打开Dialog时它是空的!为什么renderPartial部分没有执行?如何填充Dialog ??
答案 0 :(得分:1)
试试这个,
<iframe id="cru-frame-RefNew"src=""width="100%" height="100%" frameBorder="0" scrolling="yes" ></iframe>
在你的剧本中
<?php
Yii::app()->clientScript->registerScript('uploaddfsfd', "
$('#reflist-button').click(function() {
$('#RefList-New').dialog('open');
$('#cru-frame-RefNew').attr('src','".CController::createUrl('yourAction',array('id'=>$model->id))."');
return false;
});
");
?>
在你的行动中
public function actionYourAction()
{
//renderPartial here
}
如果您想在同一个对话框中添加一个iframe,请添加like,
$('#cru-frame-RefNew').attr('src','".CController::createUrl('yourAction',array('id'=>$model->id))."');
return false;
});
答案 1 :(得分:0)
1,使用src
<iframe id="cru-frame-RefNew"
width="100%" height="100%" frameBorder="0" scrolling="no"
src="<?php echo $this->createUrl('reflist') ?>" >
2,向控制器添加动作
function actionReflist() {
// fill $model and $base
// add special layout for display it in popups dialogs
$this->layout = "layouts/special_layouts_for_popup_dialogs.php";
$this->render('reflist_New', array('model'=>$model,'base'=>$base));
}