article

Saturday, March 22, 2014

Make checkbox using ajax load in yiiframework

Make checkbox using ajax load in yiiframework


 
<?php echo CHtml::checkBox("load_ajax",false,array('id'=>'load_risk_all'));echo "Load All Risk Child";
$url=CController::createUrl('project/vieweach',array('project_id'=>$model->project_id));
Yii::app()->clientScript->registerScript("check",
           '$("#load_risk_all").change(function(){
             if($(this).is(":checked")){
              $("#load_risk").load("'.$url.'");
              $("#load_risk").fadeIn();
             }else{
              $("#load_risk").html("");
             }
             })
          ',
           CClientScript::POS_READY);
 
?>
<div id="load_risk">
</div>

load() function in jQuery for loading the ajax content using $.ajax functions
$this->renderPartial('/risk/view_each',array('provider'=>$provider),false,true);

onChange event in checkbox htmlOption for supporting your own javascript model 
<?php echo CHtml::checkbox("load risk",false,array("onChange"=>"js:yourcustomfunction()")); ?> 

Related Post