問題:指望在cgridview中點擊設置的button傳遞id號到CJuiDialog中,進行處理,先看結果:
解決步驟:
javascript
1、在buttons中利用js獲取當前按鈕的連接,進而利用ajax傳遞值
2、在cgridview這個視圖中定義這個彈出層:php
html
<!--the dialog for updatAdCode begin -->
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'updateAdCodeDialog',
// additional javascript options for the dialog plugin
'options'=>array(
'title'=>'更改Img/Flash',
'modal' => true,
'autoOpen'=>false,
'minWidth' => '500',
),
));
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
<!--the dialog for updatAdCode over -->java
3、model中:ajax
app
/*
* get the ajax request and echo the html content
*/
public function actionShowAdCode()
{
if (Yii::app()->request->isAjaxRequest)
{
$ad_id = $_GET['id'];
$model_for_dialog = Ad::model()->findByPk($ad_id);
echo $this->renderPartial('_updateAdCode', array('model' => $model_for_dialog));
}
}yiipost
4、_updateAdCode.phpui
5、UpdateAdCode
this
用這種方法感受不太好,有點麻煩,不如用其餘的插件
參考資料:http://www.yiiframework.com/forum/index.php/topic/19586-ajaxlink-in-cgridview/(本案例中用的方法)
http://www.yiiframework.com/forum/index.php/topic/23807-how-do-i-post-value-to-cjuidialog/
http://www.yiiframework.com/forum/index.php/topic/19586-ajaxlink-in-cgridview/
http://www.yiiframework.com/forum/index.php/topic/9931-how-to-call-cjuidialog-in-cgridview/
http://stackoverflow.com/questions/7708455/how-to-pass-the-view-id-to-the-cjuidialog-box