CJuiAutoComplete , onClick handler

Dear All,

In CJuiAutoComplete I am displaying "Search" as a default value and clicking on autocompleate text field I want to clear that text . I tried using "click" but it is not working . Could any one please suggest me the solution ?


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


	'value' =>'Search',

   'source'=>'js: function(request, response) {


		   url: "'.$this->createUrl('myAutoComplete/autoCompleate').'",

		   dataType: "json",

		   data: {

			   term: request.term,

			   brand: $("#type").val()


		   success: function (data) {





	 'options' => array(

					'showAnim' => 'fold',

					'select' => 'js:function(event, ui){ alert(ui.item.value) }',

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

						  alert("This is a test");






Yii fan

try the ‘focus’ event instead of click

Thank You Mukesh but unfortunately even focus is not working . Focus only gets activated when I try to select one one of the options in autocompleate ( I mean the focus is for the items display in the list for auto compleate )

Could you please correct me if I am wrong ?


Yii Fan

Why don’t you try using the onFocus attribute in htmlOptions, instead of options -

'htmlOptions=>array('onFocus'=>'js:function( event, ui ) { 

                                                  alert("This is a test"); 

                                                                }', )

Thank You Mukesh for this hint Finally the below code worked

 'htmlOptions' => array(

									     'onFocus' => 'document.getElementById("searchAuto").value=""'


I think js:function( event, ui ) won’t work in htmlOptions …

Once again thank you


Yii Fan

Why don’t use

'htmlOptions' => array(





It much easier.