CJuiAutoComplete - Receive Results but nothing appears

I stuck with this problem for days and still found no solution,

I’m using CJuiAutoComplete widget, retrieving data using ajax,

Following autocomplete tutorial, I created a new action and saved it as an extension




class EAutoCompleteAction extends CAction

{

    public $model;

    public $attribute;

    private $_results = array();


    public function run()

    {

        if (isset($this->model) && isset($this->attribute)) {

            $criteria = new CDbCriteria();

            $criteria->limit = 20;

            $criteria->addSearchCondition('cityname', $_GET['term'], true);

            $model = new $this->model;

            foreach ($model->findAll($criteria) as $m) {

                $this->_results[] = array(

                    'id' => $m->id,

                    'cityName' => $m->cityname,

                );

            }

            echo CJSON::encode($this->_results);

        }

        Yii::app()->end();

    }



I’ve added it to a controller and used a widget:




public function actions() {

        return array(

            'clist' => array(

                'class' => 'application.extensions.EAutoCompleteAction',

                'model' => 'City',

                'attribute' => 'cityname',

            ),

        );

}






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

    array(

        'sourceUrl' => array('ride/clist'),

        'name' => 'cityName',

        'htmlOptions' => array(

            'id' => 'displayName',

        ),

        'options' => array(

            'showAnim' => 'fold',

            'minLength' => '2',

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

                $('#realCity').val(ui.item['id']);

                $('#displayName').val(ui.item['cityName']);

            }",

        ),


    ));



When debugging javascript, I can see that the data is being retrieved, this is what I get (data is Hebrew strings):

[{"id":"902","cityName":" \u05e8\u05d0\u05e9 \u05d4\u05e0\u05d9\u05e7\u05e8\u05d4"},{"id":"903","cityName":" \u05e8\u05d0\u05e9 \u05d4\u05e2\u05d9\u05df"},{"id":"904","cityName":" \u05e8\u05d0\u05e9 \u05e4\u05d9\u05e0\u05d4"},{"id":"905","cityName":" \u05e8\u05d0\u05e9 \u05e6\u05d5\u05e8\u05d9\u05dd"},{"id":"906","cityName":" \u05e8\u05d0\u05e9\u05d5\u05df \u05dc\u05e6\u05d9\u05d5\u05df"}]

However the autocomplete list has 5 empty elements in it.

Any help would be appreciated

This may help.

/Tommy