I am traying to use “SELECT2” extenssion with YII. I folowed the tuto step by step but it’s not working.
The dropdownlist for autocoplete doesn’t apear and I am getting this erro in chrome console
Uncaught TypeError: Object [object Object] has no method 'select2'
What I am doing wrong please ?
Thank you.
The controller code (HavesController)
public function actionTitleName(){
$model =PropProjectEn::model()->findAll ('Title like :Title',array(':Title'=>"%".$_GET['q']."%"));
$result = array();
foreach ($model as $PropProjectEn){
$result[] = array(
'id'=>$PropProjectEn->id,
'term'=>$PropUnitEn->TitleName,
);
}
echo CJSON::encode($result);
}
the view code (_propertysearch)
echo CHtml::beginForm(CHtml::normalizeUrl(array('Haves/create')), 'get', array('id'=>'filter-form'))
. '<div class="row" style="width:100%;">'
. CHtml::encode('Project Title')
. CHtml::textField('TitleName',(isset($_GET['TitleName'])) ? $_GET['TitleName'] : '',array('id'=>'TitleName'));
$this->widget('ext.select2.ESelect2',array(
'selector' => '#Title',
'options' => array(
'allowClear'=>true,
'placeholder'=>'Select a Project Name',
'minimumInputLength' => 2,
'ajax' => array(
'url' => Yii::app()->createUrl('Haves/TitleName'),
'type'=>'GET',
'dataType' => 'json',
'quietMillis'=> 100,
'data' => ' function(term,page) {
return {
//get im my controller
q: term,
};
}',
'results'=>'function(data,page) { return {results: data, more:more }; }',
),
),
));
echo '</div>'