laktek / jQuery-Smart-Auto-Complete

AutoComplete plugin with smart defaults and flexibility to customize
http://laktek.com/2011/03/03/introducing-jquery-smart-autocomplete/
248 stars 34 forks source link

Working with ids? #12

Open OleLaursen opened 12 years ago

OleLaursen commented 12 years ago

With select boxes, the labels and the actual values of the options are decoupled so you can show a nice formatted text to the user and still get an id back to plug directly into the database. I couldn't find an easy way of doing that with your plugin?

laktek commented 12 years ago

You can use the resultFormatter option to pass the formatted text to show (check the 7th example in the demo page). Then with the itemSelect event you can get a value (or an id) to send back to the backend.

OleLaursen commented 12 years ago

Did you try doing this? I think I looked at the source code and concluded I might end up with a problem. I need to be able to control it the other way around too, i.e. I need to be able to choose a certain id/value if the user presses a button.

In any case, it's not easy to do. :) I don't think it's a bug, just a suggestion for something you may want to improve on. I realize it depends on whether you're using the combo box for free form input or as a select box with a fixed set of values.