Adding function options to autocomplete

I’m trying to add some functionality for the ‘beforeSend’ on autocomplete, I want to replace the search button to a loading icon when requesting auto complete values from the server.

So the code I might have is:




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

	'name'=>'keywords',

	'sourceUrl'=>array('goal/goalAutocomplete'),

	'value' => $this->search_keywords,

	// additional javascript options for the autocomplete plugin

	'options'=>array(

		'minLength'=>'2',

		'beforeSend' => 'function() { // add some functionality here for  loading icon }'

	),

	'htmlOptions'=>array(

		'class'=>'itext',

		'alt' => t('Search for goals...')

	),

));



The problem is that the output of the code is putting quotations around the ‘function() …’ part of the ‘beforeSend’ so its treating it as a JavaScript string rather than code.

Hope this is clear?

Try with the js: to mark it as script code




'beforeSend' => 'js:function() {...}