Toggle Slide with jquery in my FAQ page contents

Guys,

First i am telling about my project,

I develop a project where i add a FAQ page, the questions and associative answers. now i want, when i hover my mouse to a question, with jquery, the associative answer will be popup. (questions and answers are generated from database).

Now, in my controller i added these:

public function actionIndex()

{


	$criteria=new CDbCriteria(array('condition'=>'status='.Faq::STATUS_ACTIVE,));


	





	


	$dataProvider=new CActiveDataProvider('Faq', 


		array(


			'criteria'=>$criteria,


			'pagination'=>array(


			'pageSize'=>8,),


	));


	


	$this->render('index',array(


		'dataProvider'=>$dataProvider,





		


	));


}

public function loadModel()

{


	if($this->_model===null)


	{


		if(isset($_GET['id']))


		{


			//$this->_model=Faq::model()->findbyPk($_GET['id']);


			


			if(Yii::app()->user->isGuest)


				$condition='status='.Faq::STATUS_ACTIVE.' OR status='.Faq::STATUS_INACTIVE;


			else


				$condition='';


			$this->_model=Faq::model()->findByPk($_GET['id'], $condition);	


			


		}


		if($this->_model===null)


			throw new CHttpException(404,'The requested page does not exist.');


	}


	return $this->_model;


	


	


}

And in my view:

index.php:

<?php

$this->widget(‘zii.widgets.CListView’, array(

'dataProvider'=&gt;&#036;dataProvider,


'itemView'=&gt;'_view',


'summaryText' =&gt; '',


)); 

?>

and,

_view.php:

<?php echo CHtml::encode($data->getAttributeLabel(‘ques’)); ?>:

<?php echo CHtml::encode($data->ques); ?>

<?php echo CHtml::encode($data->getAttributeLabel(‘ans’)); ?>:

<?php echo CHtml::encode($data->ans); ?>

Here, all data are shown, please if i bother you with my codes forgive me.

But i really need helps. Thanks<tanim>

Do you mean showing/hiding the answer? You can do this as far as I know:




<div id="question">

   <?php echo CHtml::encode($data->getAttributeLabel('ques')); ?>:

   <?php echo CHtml::encode($data->ques); ?>

</div>


<div id="answer" style="display:none">

   <?php echo CHtml::encode($data->getAttributeLabel('ans')); ?>:

   <?php echo CHtml::encode($data->ans); ?>

</div>



You may also need to register your script:




Yii::app()->clientScript->registerScript('show', "

$('#question').hover(function(){

   $('#answer').toggle();

});

");



Cheers,

Rei

P.S. Next time, please surround your code with code tag, so that other users can read it more easily.

Many many thanks for reply, but your code only works for first data, other data are not shown. <tanim>

Guys… :blink: you all forgot me ? really i need help man, the above code only toggle first data from database, others are not showing… thanks <tanim>

Ok, thanks to the forum members, they replays so fast as we (novice) needed, one of bro gave me the solution, hope it will help the people like me ,

Toggle associative div