Including Js/ajax Functions

Hello Everyone, Yii newbie here :)

I have tried more than once to figure out a way to include an Ajax/JS function in an easy clean way in my CGRIDVIEW,

the code is basically


'click'=> "function (){

    $.fn.yiiGridView.update('news-grid', {

        type:'POST',

        url:$(this).attr('href'),

        success:function(data) {

            $('#AjFlash').html(data).fadeIn().animate({

                opacity: 1.0

            }, 3000).fadeOut('slow');

 

            $.fn.yiiGridView.update('news-grid');

        }

    })

    return false;

}"



In your opinion, whats the cleanest, most performance benificial way to include this?

Thank you for your time !!!