Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yii-cms/yii2-typeahead
Typeahead widget for Yii2 framework.
https://github.com/yii-cms/yii2-typeahead
Last synced: 26 days ago
JSON representation
Typeahead widget for Yii2 framework.
- Host: GitHub
- URL: https://github.com/yii-cms/yii2-typeahead
- Owner: yii-cms
- Created: 2015-07-01T09:26:27.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-11T07:54:36.000Z (about 9 years ago)
- Last Synced: 2024-11-08T11:52:09.801Z (about 2 months ago)
- Language: PHP
- Size: 141 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# yii2-typeahead
Typeahead widget for Yii2 framework.```php
'typeahead-id',
'name' => 'typeahead-name',
'clientOptions' => [
'displayKey' => 'value',
'templates' => [
'suggestion' => new JsExpression("function(data){ return '' + data.value + '
'; }"),
],
],
'events' => [
'typeahead:selected' => new JsExpression(
'function(obj, datum, name) { window.location = datum.url; }'
),
],
'bloodhoundOptions' => [
'remote' => [
'url' => Url::to(['controller/action']) . '?q=%QUERY',
'ajax' => ['data' => [
'id' => $model->id,
]],
'replace' => new JsExpression("
function(url, query) {
return url.replace('%QUERY', query);
}
"),
'filter' => new JsExpression("
function(list) {
return $.map(list, function(item) { return { value: item.name, url: item.url }; });
}
"),
],
],
'options' => ['class' => 'form-control', 'placeholder' => 'Title', 'autofocus' => true],
]);
```