My goal is to display a profile page which includes paginated comments, so
I’m rendering a view (viewprofile) from my controller which renders partial another view (listcomments).
In the listcomments view I include the widget CListView which renders the _listcomments view via the itemView option. The _listcomments uses the CStarRating widget.
Everything is ok in the first load of the page and the _listcmoments is rendered with the stars of the CStarRating widget, but when i click on the next page the results (the values are correct) display the radio buttons instead of CStarRating’s stars.
I’ve seen in other answers in the forum that i should renderpartial the listcomments view with the processOutput=false, which i did but I still have the same problem.
The 3rd param (true) should return the results instead of displaying them and the 4th param (true) should register the scripts necessary for the CStarRating widget. Let me know if this works.
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 40961 bytes) in C:\var\yii-framework\yii-1.1.6.r2877\framework\web\CBaseController.php on line 117
That happens when i try to renderPartial the _listcomments inside the _listcomments view…
I’ll play a bit with the above and i’ll let you know the results…
I believe Yii is setting both widget (CListView and CStarRating) containers to the same Id. I have tested it on my machine and I can page while keeping the CStarRating widget intact. See screenshot. Sorry for the previous, long workarounds.
This is my solution. This is a solution that I use for CListViews because I don’t like to turn on scripts for Ajaxrequests as this seems to cause unexpected behavior (such as the problems mentioned here.)
I call actions based on the mouse entering the div container of the list view.
For example,
$(’.list-view’).live(‘mouseenter’,function() { //list-view is the id of the div containing my list view
//code here
}
Inside this, I place scripts or actions that I want to have executed after pagination. It is not perfect, as it will run only when the user mouseovers the container. But I’m not sure how else to do this.
Anyway, for Cstarrating, I have placed this code inside.
jQuery(’.starRating > input’).rating(
{‘starWidth’:22,‘callback’:fookie} //these are the widget parameters
);
Make sure to add a class name (here, ‘starRating’) to your star widget
$this->widget(‘CStarRating’,
array(
…
‘htmlOptions’=>array(
'class'=>'starRating'
…
),
This should work without messing anything else up ~…
Your solution works but now it refreshes the page on paginate and that’s why it work. There’s no more ajax pagination. And also the url gets uglier with some params.
as commented, changing the id makes the page loaded after pagination, not ajax pagination
using afterAjaxUpdate and calling rating the starRating is rendered but seems its done with the item default values, if you’ve choosen allowEmpty false the forbidden symbol is showing, if you had readOnly is always read/write. What is working is the ‘value’ property