Question

I'm new to Yii and I've been able to use CJuiAutoComplete for autocomplete.

I have two questions:

  1. By default, the input box is of type text. How can I change the type to search?
  2. By default it uses jQuery UI CSS styling. How can I drop that and use my own styling?

    $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
        'model' => $myModel,
        'attribute' => 'name',
        'source' => Yii::app()->createUrl('search/autocomplete'),
        'options' => array(
            'minLength' => '2',
            'showAnim' => 'fold',
            'select' => 'js: function(event, ui) {
                this.value = ui.item.value;
                $("#item_id").val(ui.item.id);
                return false;
            }',
        ),
        'htmlOptions' => array(
            'maxlength' => 50,
            'type' => 'search' // <- This didn't work
        ),
    ));
    
Was it helpful?

Solution

2) For this you can specify the css file using the cssFile attribute this defaults to "jquery-ui.css" you can change to your own file; see this documentation for more details see http://www.yiiframework.com/doc/api/1.1/CJuiWidget#cssFile-detail

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top