Implementing Javascript Events in CJuiAutoComplete

My input field was like this:


<input type="text" id="txtKeyword" name="txtKeyword" class="input_form1" value="Enter City name, District name, Property name..."   autocomplete="off" onfocus="javascript:shuffle(this);jQuery(this).autocomplete({ajax_get:get_answers});" onblur="javascript:shuffle(this);" />

What do I need to do to put these two events in the widget ?

onfocus="javascript:shuffle(this);" onblur="javascript:shuffle(this);"


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

    'id'=>'txtKeyword',

    'name'=>'txtKeyword',

	'value'=>"Enter City name, District name, Property name...",

	'source' => CController::createUrl('site/suggest'),

    'options'=>array(

        'delay'=>300,

        'minLength'=>2,

        'showAnim'=>'fold',

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

            $('#label').val(ui.item.label);

        }"

    ),

    'htmlOptions'=>array(

        'size'=>'77',

		'style'=>"font-size: 13px; font-family: Arial,Helvetica,sans-serif; line-height: 28px; height: 28px;"

    ),

I am a Yii newbie too, but I guess this will help you. The code below calls the shuffle function on focus event. You can try "blur" too, however I am not sure if that will work





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

    'id'=>'txtKeyword',

    'name'=>'txtKeyword',

        'value'=>"Enter City name, District name, Property name...",

        'source' => CController::createUrl('site/suggest'),

    'options'=>array(

        'focus'=>'js:shuffle(this)',

        'delay'=>300,

        'minLength'=>2,

        'showAnim'=>'fold',

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

            $('#label').val(ui.item.label);

        }"

    ),

    'htmlOptions'=>array(

        'size'=>'77',

                'style'=>"font-size: 13px; font-family: Arial,Helvetica,sans-serif; line-height: 28px; height: 28px;"

    ),




That didn’t work

According to http://jqueryui.com/demos/autocomplete/#event-focus


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

    'id'=>'txtKeyword',

    'name'=>'txtKeyword',

    'value'=>"Enter City name, District name, Property name...",

    'source' => CController::createUrl('site/suggest'),

    'options'=>array(

        'focus'=>'js:function(event, ui) { // see here?

            shuffle(this);

        }',

        'delay'=>300,

        'minLength'=>2,

        'showAnim'=>'fold',

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

            $('#label').val(ui.item.label);

        }"

    ),

    'htmlOptions'=>array(

        'size'=>'77',

        'style'=>"font-size: 13px; font-family: Arial,Helvetica,sans-serif; line-height: 28px; height: 28px;"

    ),

));

This is not working.

‘options’=>array(

	[b]'create'=&gt;'js:function(event, ui) {


        shuffle(this);


    }',[/b]

this works but not giving the desired functionality. The value "Enter City name, District name, Property name…" in text field is empty on page load.