Here is my problem:
My stars display properly when I don’t change to another page:
Here is my codes in my _view.php and my controller about pages
Any ideas about why?
_view.php:
div <class="rating">
$rating = Rating::model()->findByPk($data->rating_id);
if ( isset($rating->vote_average) ){
$value = round($rating->vote_average,0);
}else{
$value = 0;
}
$this->widget('CStarRating',array(
'name'=>'rating'.$data->rating_id, // an unique name
'starCount'=>5,
'readOnly'=>true,
'value'=>$value,
));
?>
I have added the afterAjaxUpdate but it seems like it is not correct…because it will render stars but only 2stars…instead of 5.
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$notesDataProvider,
'itemView'=>'/notes/_view',
'sortableAttributes'=>array(
// 'name',
'create_time',
),
'afterAjaxUpdate'=>'function(id,data){ $(\'div.rating \').rating(); }',
));
?>
See images: