widget CStarRating check if cancel voting

Hi

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')); ?>

<script>

    function test(){

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

    }

</script>

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');

    });



Thanks

Finally I found a solution


<script>

    function test(value){

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

            alert ('vote is ' + value);

        } else {

            alert ('cancel vote clicked!');

        }

    }

</script>

Both of stars and cancel button call the same callback function

Please check this

I hope it’s some help…:)