Make CJavaScript::encode() recognise JavaScript's function literal

There are times I need to write function literals to be passed to the options part of a JUI widget, but failed to do that. Consider this:




$this->widget('zii.widgets.jui.CJuiAutoComplete', array(

    'name'=>'city',

    'source'=>array('ac1', 'ac2', 'ac3'),

    // additional javascript options for the autocomplete plugin

    'options'=>array(

        'minLength'=>'2',

    ),

    'htmlOptions'=>array(

        'style'=>'height:20px;'

    ),

));



I want to do this:




    'options'=>array(

        'minLength'=>'2',

        'select'=>'function( event, ui ) {

            1+1;

        }',

    ),



And yii will recognised it is a javascript function and unquote it, instead of currently this




{'minLength':'2', 'select':'function( event, ui) { 1+1; }'}



Check out my blog on how I use regex to unquote javascript function literals

http://tipstank.com/2010/10/29/how-to-add-javascript-function-expression-and-php-json_encode/

Just notice one can add "js:" in front of value to make it unquote,

Means I should do




   'options'=>array(

        'minLength'=>'2',

        'select'=>'js:function( event, ui ) {

            1+1;

        }',

    ),



please close my feature request. Thanks!