Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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],
]);
```