I’m newbie.
I’ve searched for the same problem on this board.
But I couldn’t find the clear answer.
What i want to do is that
CListView shows each the content in _itemView.php.
if user move mouse onto image box div in _itemView.php, then rollover div in _itemView should come out.
for this purpose, I inserted javascript code in _itemView.php.
the js code needs to know $data->id. That’s why i inserted the code in _itemView.php.
But this works fine only first page.
When i go to next page, the rollover div don’t come out.
I tried to use ‘afterAjaxUpdate’ option in CListView and insert js:function in the option.
But I couldn’t solve it.
Also I tried to use Yii::app()->clientScript. I couldn’t solve it too.
What should i do ?
Here’s my code.
Controller
public function actionIndexByInt(){
....
$this->render('_indexTileList', array(
'dataProvider'=>$dataProvider,
));
}
_indexTileList.php
<?php
$this->layout='//layouts/column1';
$dataProvider->pagination->pageSize = 12;
?>
<div class="list_box">
<?php
$this->widget('zii.widgets.CListView', array(
'id'=>'product-list',
'dataProvider'=>$dataProvider,
'cssFile' => Yii::app()->baseUrl . '/css/listViewStyle/listView_user_page.css',
'pager' => array('cssFile' => Yii::app()->baseUrl . '/css/listViewStyle/listView_user_page.css',
'prevPageLabel'=>'< Prev',
'header'=>'',
'htmlOptions'=>array('onclick'=>'javascript:to_top();'),
'pageSize'=>10,),
'itemView'=>'_itemView', // refers to the partial view named '_itemView'
'template'=>'{items}<br /><hr id="change_line" />{pager}',
'sortableAttributes'=>array(
'price',
),
));
?>
</div>
_itemView.php
<script type="text/javascript">
$(document).ready(function(){
var n = 0;
$("div.img_div<?php echo $data->id ?>").mouseenter(function(){
MM_showHideLayers('item<?php echo $data->id ?>','','show'); //MM_showHideLayers() is custom function.
}).mouseleave(function(){
MM_showHideLayers('item<?php echo $data->id ?>','','hide');
});
});
</script>
<div class="item_box">
<!-- image box div -->
<div class="img_div<?php echo $data->id ?>" style="border:1px solid silver;">
<!--rollover div-->
<div class="rollover_info" id="item<?php echo $data->id ?>">
<div class="rollover_title"> <b><?php echo Yii::app()->utility->shortenStr($data->name, 20);?></b></div>
...
</div>
<!-- end rollover div -->
...
</div>
<!-- end image box div -->
...
</div>