CStarRating not work, has no method 'rating()'

Hello all,

I am new to YII, And I got a problem with CStarRating

Here is my code to create rating


<?php $this->widget('CStarRating',array('model' => $model, 'attribute'=>'rating',

                      'ratingStepSize'=>2,

                      'maxRating'=>10,

                      'minRating'=>1,

                       'name'=>'Topic[rating]',

                       'allowEmpty' =>false));?>



But it did not show the images, only the options. I inspected the output HTML and found an javascript error message:


Uncaught TypeError: Object #<an Object> has no method 'rating'

I also found that the js file (jquery.rating.js) already registered at /assets/87870dfa/jquery.rating.js and it has $.fn.rating method.

I downloaded a copy of this js file, placed it in my custom js folder and manually registered it, the stars appeared.

How do I solve this problem without manually register js file?

Thanks

instead of setting name, set model and attribute

model=$topicModel

attribute=‘rating’

Thanks for your reply.

But the problem is not widget.

My problem is: "jquery.rating.js" already registered but javascript error occur at "rating" method not found

First I would make sure you don’t have some kind of cached javascript problem (i.e. it is actually working, just not for you). Also, does your star rating control appear in a dialog that is populated via an AJAX request? A while ago I had some similar problems with the JavaScript of the star rating control in a dialog being loaded too many times (or something that I never had time to fully figure out) and I resorted to rendering the dialog contents in a hidden div when the page was first rendered instead of dynamically when the button was clicked. There is definitely a problem with the control when there is more dynamic rendering going on besides just the conversion of the radio buttons to stars. Like I said, I didn’t have time to figure it all out.

My 2 cents.

I have same problem. How I register it manually?!

http://jquery-star-rating-plugin.googlecode.com/svn-history/r38/trunk/jquery.rating.js

download the jquery rating file here, then place it somewhere in your folders, then use the

$clientScript = Yii::app()->getClientScript();

$clientScript->registerScriptFile(‘path to your rating.js file’);

is there a way to hide or remove the cstar rating, cancel rating button?