muhiddingithub/yii2-autocomplete
Composer 安装命令:
composer require muhiddingithub/yii2-autocomplete
包简介
yii2-autocomplete jquery ui
README 文档
README
yii2-autocomplete jquery ui Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require muhiddingithub/yii2-autocomplete "dev-master"
or add
"muhiddingithub/yii2-autocomplete": "dev-master"
to the require section of your composer.json file.
Usage
echo \muhiddin\autocomplete\AutoComplete::widget([ 'id' => 'search', 'form'=>$form, // ActiveForm widget object 'model'=>$model, // model 'attribute'=>'model_attribute', // attribute of model 'value' => '', 'name' => 'name', 'options' => [ 'class' => 'form-control form-group-margin', 'dir' => "ltr", 'placeholder' => "search", ], 'pluginOptions' => [ 'minChars' => 3, 'serviceUrl' => \yii\helpers\Url::toRoute(['custom-controlller/customer-action']), 'width' => '40%', 'onSelect' => 'function(suggestion){ // call onselect found element function }' ] ])
in custom-controlller/customer-action
$query = Yii::$app->request->get('query');
if (!empty($query)) {
$find = MyModel::find()->andFilterWhere(['like','column_name',$query]);
$allModels = $find->column();
echo json_encode([
'suggestions' => $allModels
]);
} else {
echo json_encode(['status' => 'failure']);
}
统计信息
- 总下载量: 133
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-25