dongqiuge5435 2014-06-30 08:43
浏览 38

使用dropDownList请求后的renderPartial

First, note that I have noticed that the common Yii widgets that have paginators, can go to any page without reloading the page, but just requesting it via AJAX and then changing the content of the already loaded page. Such behavior will completely satisfy my current needs.

I have a simple dropDownList in one of my views. What I'm trying to do is to change the content of the page without reloading the page, just like Yii's widgets.

Is that possible? How?

I tried doing something like this in my controller:

if(Yii::app()->request->isAjaxRequest){
    $this->renderPartial(.....);
}

and this in my dropDownList:

<?php
    echo CHtml::dropDownList('usage', 'cg', array(
        'd'=>'Daily',
        'm'=>'Monthly'
    ), array(
        'submit'=>array('admin/user', 'id'=>$user->iduser),
        'params'=>array('cg'=>'js:$(this).val()'),
        'options'=>array(
            Yii::app()->session['cg']=>array(
                'selected'=>true
            )
        )
    ));
?>

but the dropDownList keeps reloading the page.

  • 写回答

1条回答 默认 最新

  • dtwknzk3764 2014-06-30 09:47
    关注

    I have done the following to reload content of div depending upon the selected value of dropDownList.Might be helpful to you.

    echo CHtml::dropDownList('usage','cg',array('d'=>'Daily','m'=>'Monthly'),array('ajax'=>array(
            'type'=>'POST', //request type
            'url'=>$this->createUrl('controller/loadContent'), //url to call.
            'update'=>'#div_id',//div to update
            'data'=>array('cg'=>'js:this.value') 
            ))); 
    
    
    public function actionLoadContent()
    {
       ..........
       ..........
       $this->renderPartial('_ajaxContent', $data, false, true);
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思