Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Image Preview Onclick

$
0
0
Hai i have a thumbnails that list all images, now when i click each img it should have a img preview a bigger one..
here is my view code
foreach($model_image as $i){
			  echo "<li>".CHtml::link(   
				CHtml::image('/../images/'.$i->news_photos,'',
				array('style'=>"width:150px;height:60px")
				),'#',
							
							array(
									 
									'ajax'=>array(
									'type'=>'POST',
									'url'=>CController::createUrl('test/Imgpreview'),
									'data'=>array('id'=>$i->id),
									 
									'update'=>'#imgpreview',
									)
									 
								 
									) 
		 
					
					) ."</li>";
 
						
			}
			
  
			?>
 
 
 <div id="imgpreview"></div>


and in my controller code
public function actionImgpreview(){       
        $model=news::model()->findAll('id=:id',
			array(':id'=>$_POST['id']));
			$return=CHtml::listData($model,'news_photos','id');
			foreach($return as $imagenews=>$image){
        
     
     echo CHtml::image('/../images'.$image->news_photos, 
							array('style'=>'height:300px;width:300px;'));  
		}
	}


Viewing all articles
Browse latest Browse all 18717

Trending Articles