Simple question really - how do I use text_field_with_auto_complete
inside a form_for
block?
I\'ve tried doing f.text_field_with_auto_com
If your intent is to set a id field, you must:
render the results in LI items, each li having it DOM id set up to the id of the returned record, like this:
- Item 1
< LI ID="2">Item 2< /LI>
Your text field would be something like:
<%= text_field_with_auto_complete :model, :method, {}, :after_update_element => ‘getSelectionId’ % >
and a javascript method called getSelectionId like this
function getSelectionId(text, li) {
alert (li.id);
}
note that you can do anything via javascript since you have the text and the li element available.
Another option is this plugin