P.Linux 2011-11-22 14:42:02 3519次浏览 0条回复 0 0 0

我想在一个页面内分多个tab,每个tab下的内容都是Ajax更新的,但是我按我的写法,最后Ajax会覆盖页面。 view:

$view_data = array(
    'cluster_name' => $cluster_name,
    'host_ip' => $host_ip,
    'instance_ip' => $instance_ip,
    'collect_status'=>$collect_status,
    'comment' => $comment,
    'Avg_Innodb_rows_read' => $Avg_Innodb_rows_read,
    'Avg_Innodb_rows_inserted' => $Avg_Innodb_rows_inserted,
    'Avg_Innodb_rows_updated' => $Avg_Innodb_rows_updated,
    'Avg_Innodb_rows_deleted' => $Avg_Innodb_rows_deleted,
);
$this->widget('zii.widgets.jui.CJuiTabs', array(
    'tabs'=>array(
        'InnoSB Status' => $this->renderPartial('_innodb_status', $view_data, true),
        'MySQL Processlist' => $this->renderPartial('_mysql_processlist', $view_data, true),
    ),  
    // additional javascript options for the tabs plugin
    'options'=>array(
        'collapsible'=>false,
    ),  
));
$ajax = CHtml::ajax (
    array(
        'url'=>CController::createUrl('status/UpdateAjax'),
        'update'=>'#status_monitor'
    )   
);
Yii::app()->clientScript->registerScript('update_div', "
    function update_div() { $ajax } 
    setInterval(update_div, 2000);", 
    CClientScript::POS_READY);


controller:
    public function actionUpdateAjax()
    {   
        $this->loadInstanceStatus();
        $data = array();

        foreach ($_SESSION as $key=>$value) {
            $data[$key] = $_SESSION[$key];
        }   
        $data["collect_status"] = "采集运行中";
        $data["comment"]        = "系统运行良好";
    
        $this->renderPartial('_innodb_status', $data, false, true);
        #$this->renderPartial('_mysql_processlist', $data, false, true);
    }

结果Ajax刷新时把tab都刷没了,就剩_innodb_status.php里面的内容了,不在tab内

    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册