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/