views:

175

answers:

2

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 (probably 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

+3  A: 

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

christian studer
I was just exploring that... is there any simple way to pass the id of the result that is being suggested?
ile
Hmm, I'm never really sure which one to take: Try $(this).val() for example. Otherwise the event handler passes two parameters, ui and event. Have a look at the documentation for those.
christian studer
I'm not sure if you understood my question, I edited it, so if you could please take a look. Thanks!
ile
A: 

I found the answer here: http://jqueryui.com/demos/autocomplete/

There are many examples and explained.

ile