yii-cms/yii2-typeahead Typeahead widget for Yii2 framework.

typeahead

yii2-typeahead

Typeahead widget for Yii2 framework.

            <?php echo Typeahead::widget([
                'id' => 'typeahead-id',
                'name' => 'typeahead-name',
                'clientOptions' => [
                    'displayKey' => 'value',
                    'templates' => [
                        'suggestion' => new JsExpression("function(data){ return '<p>' + data.value + '</p>'; }"),
                    ],
                ],
                '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],
            ]);

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

  • 0.211 November 2015
  • v0.101 July 2015

Comments



0.2 is the latest of 2 releases



Unknown license
Stats
0 github stars & 0 github forks
2 downloads in the last day
169 downloads in the last 30 days
17639 total downloads