CJuiAutoComplete not working


(nelsonpacheco15) #1

Hey!
Im new here in the forum, and also new to yii… So hello everyone!

I have a issue with the autocomplete widget…
I create a action in my controller to display sugestions of titles when Im typing in the field, then I add the code to teh view, but nothing happens, no sugestions… Sometimes appears a jquery error…

Action:

public function actionGetTitles($term) {
        $model = Node::model()->findAll(
                array(
                    'select' => 'title',
                    'condition' => 'title LIKE :string',
                    'params' => array(
                        ':string' => $term . '%',
                    )
                )
        );
        foreach ($model as $modelos) {
            $json_array[] = $modelos->title;
        }
        $json = CJSON::encode($json_array);
        echo $json;
    }

View:

<div class="row">
                                    <div class="col-lg-12">

                                        <?php echo CHtml::label('Pesquisar Titulo', 'search'); ?><br />
                                        <?php $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
                                          'name' => 'search',
                                          'source'=>$this->createUrl("node/getTitles"),
                                          // additional javascript options for the autocomplete plugin
                                          'options' => array(
                                          'showAnim' => 'fold',
                                          ),
                                          'htmlOptions' => array(
                                          'class' => 'form-control',
                                          ),
                                          )); 
                                        ?>
                                    </div>
                                </div>

Best regards!