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 ?


<?php


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

	'name'=>'test1',

	'value' =>'Search',

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

	   $.ajax({

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

		   dataType: "json",

		   data: {

			   term: request.term,

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

		   },

		   success: function (data) {

				   response(data);

		   }

	   })

	}',


	 'options' => array(

					'showAnim' => 'fold',

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

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

						  alert("This is a test");

								}',

	 ),

));

?>

Regards

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 ?

Regards

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

Regards

Yii Fan

Why don’t use




'htmlOptions' => array(

                            

                            'placeholder'=>'Search',

                            

                        ),



It much easier.