Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete _renderItem support #26

Open
raplider opened this issue Sep 14, 2015 · 2 comments
Open

Autocomplete _renderItem support #26

raplider opened this issue Sep 14, 2015 · 2 comments
Assignees
Labels
type:docs Documentation

Comments

@raplider
Copy link

How to create custom display items ?

@samdark
Copy link
Member

samdark commented Sep 15, 2015

According to jQueryUI API. Docs could be enhanced with more examples...

@samdark samdark self-assigned this Sep 15, 2015
@samdark samdark added the type:docs Documentation label Sep 16, 2015
@mabentley85
Copy link

@raplider I was able to accomplish custom display templates by adding the .autocomplete("instance")._renderItem function inside the create event like this:

$form->field($searchForm, 'query')->widget(AutoComplete::class, [
  'clientEvents' => [
    'create' => new JsExpression('function(event, ui) {
      $(event.target).autocomplete("instance")._renderItem = function(ul, item) {
        return $("<li>").append("<div>" + item.name + "<br>" + item.brand + "</div>").appendTo(ul);
       };
    }'),
  ],
]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:docs Documentation
Projects
None yet
Development

No branches or pull requests

3 participants