0
我正在開發一個網站,在第一次訪問時,用戶將被要求輸入電子郵件和他/她居住的城市。我使用colorbox和iframe加載它。這裏是main.php代碼:提交表格後關閉colorbox中的iframe
Yii::app()->clientScript->registerScript('',
"$('document').ready(
function()
{
$.fn.colorbox({href:'http://www.veevou.com/visitor/create',
iframe:true,'width':'365px', 'height':'510px', onClosed:function(){ location.reload(true); }});
}
)");
$colorbox = $this->widget('application.extensions.colorpowered.ColorBox');
$colorbox
->addInstance('.colorbox', array('maxHeight'=>'80%', 'maxWidth'=>'80%'));
所以,你看,顏色框將呈現頁面create.php和表單提交後,控制器將數據保存然後重定向到索引頁面。
這是控制器:
if(isset($_POST['Visitor']))
{
$model->attributes=$_POST['Visitor'];
// Register only if he/she is not registered as member nor visitor
if($model->save())
{
echo "<script>parent.$.fn.colorbox.close(); </script>";
$this->redirect(array('site/index'));
}
}
else
{
$this->render('form',compact('model'));
}
但它說:「不能修改已經發送了頭......」。如何關閉彩盒?我試圖在重定向到另一個頁面之前放置「parent。$。fn.colorbox.close();」,但它沒有奏效。我應該在哪裏放置$ .fn.colorbox.close()?我在另一篇文章中嘗試了幾種方法,但沒有一篇適合我。謝謝
Tks反饋。如何確保colorbox不再打開?控制器會將頁面重定向到index.php,並且我已經將「echo」「;」在index.php的頂部,但頁面仍然顯示在colorbox內部。 – 2012-01-31 06:29:37
管理得到解決。我使用echo – 2012-01-31 07:34:55