如何在yii中获取CJuiAutoComplete文本字段中的值?

时间:2012-11-24 14:39:24

标签: autocomplete yii

我正在使用此代码。如何将值放入变量中,比如$ temp?

$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
    'name'=>'patientSearch',
    'source'=>$arr,
    // additional javascript options for the autocomplete plugin
    'options'=>array(
        'minLength'=>'2',
),
'htmlOptions'=>array(
    'style'=>'height:20px;'
),
));

$temp = <value of autocomplete form>;

1 个答案:

答案 0 :(得分:0)

阅读此http://api.jqueryui.com/autocomplete/个活动部分。使用selectchange个活动

$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
  'name'=>'patientSearch',
  'source'=>$arr,
  // additional javascript options for the autocomplete plugin
  'options'=>array(
        'minLength'=>'2',
        'select' => 'js:function(event, ui) {
$temp = event.currentTarget.value;
}',
        'change' => 'js:function(event, ui) {
$temp = event.currentTarget.value;
}',
  ),
  'htmlOptions'=>array(
    'style'=>'height:20px;'
  ),
));

var $temp = ''; // init global variable