开发者

jquery UI autocomplete - extended data?

开发者 https://www.devze.com 2022-12-30 02:26 出处:网络
I would like to use Jquery\'s UI autocomplete but with some additional functions: after user selects suggested item, I would also like to display additional data related with that item (for example if

I would like to use Jquery's UI autocomplete but with some additional functions: after user selects suggested item, I would also like to display additional data related with that item (for example if database of contacts are being searched, then I'd like to display contact's email, addres...) in some html element.

Is there a way to accomplish this?

Thanks in advance,

Ile

EDIT:

I'd like to provide more detail description of what I actually need:

When user starts searching contacts, as a result from database I would like to return contact's ID and Full Name. After user selects certain contact, then ajax function is called and it retrieves all details from selected contact using it's ID. But I don't know how to do following:

  • As a result from database return the ID and Full Name of contact as a JSON result (p开发者_运维百科robably I would find the solution to get the right format, but I don't know how it needs to be passed to Autocomplete script)

  • How to handle the result data so that I display only full name and ID is used only when certain contact is selected, so that I can retrieve full details of certain contact


Have a look at its events: You can add a handler for the select event and display all your informations once it fires.


You can specify extra data in formatMatch function. The parameter must be some delimiter separated string. Later in .result function , which takes 3 arguments [event, data, formatted], you can retrieve it by splitting the formatted by the delimiter use and populate the required values.

0

精彩评论

暂无评论...
验证码 换一张
取 消