Javascript, Mouse Over And More?

I have a table that similar like the one in the attached file. I want to add some javascript for mouseover which means when I move to mouse pointer to an item inside div tag area, it would show a small window within detail of this item, similar like what you see in every shopping sites. So how could I do it in Yii when there are many built-in functions inside?

And also, I used findAll() to get all items detail in the controller and send it to the view. But in the view, I dont know how to use them with javascript.

As far as I know, you can’t do it directly in Yii, so you have to write some jQuery for it, or use a jQuery plugin, or find a Yii extension that wraps one…

The second question is unclear to me?

The case is:

I have $model->findAll() in controller, and send it to a view. In this view I use foreach with $model to create many buttons with id = $model->id, onclick = aFunction($model->id). If i click on the button number 3 -> run the aFunction(3).

In javascript I want somehow get the $model[3] (in php) to analyze in the aFunction() (in javascript).

Can I use $model in JQuery?

How i could use these variables with JQuery or pass them to a Jquery function?

Can’t you just pass the value in PHP to your JS function?

How to do it? I need to find $item by its id, must be query from the database.

Dear Friend

I perceive some complex situation at your hand.

But the following is very simple scenario in which we are passing the PHP variable to JavaScript function.




$medicos=Medico::model()->findAll();

	

foreach($medicos as $medico)

	{

		echo CHtml::tag('div',array("class"=>"view","id"=>$medico->id),$medico->id);

			

		Yii::app()->clientScript->registerScript($medico->id,'

			$("#"+"'.$medico->id.'").click(

				function(){alert("'.$medico->name.'");}				

			);

		');

			

	}



Kindy take note of single quotes and double quotes in registerScript method…

Regards.

Thank you :), I will test and try to change it from ‘click’ to ‘mouseover’ because I want to run a script to display item’s detail when the mouse pointer move to this div tag.