widget CStarRating check if cancel voting


I use CStarRating widget and I want to display the selected value using the callback setting

<?php $this->widget('CStarRating',array('name'=>'rating', 'callback'=>'test')); ?>


    function test(){

        alert ($(this).val());



How to do the same thing when user click on cancel button ?

May I can use the bellow code but I seek for a more robust way

 $('.rating-cancel a').click(function(){

        alert('cancel click');



Finally I found a solution


    function test(value){

        if (typeof value!== 'undefined') {

            alert ('vote is ' + value);

        } else {

            alert ('cancel vote clicked!');




Both of stars and cancel button call the same callback function

Please check this

I hope it’s some help…:)