I’d like to populate a hidden field with the ID so I don’t have to
find_by_foo_bar afterwards (and thus take yet another database hit [oy
my poor database] and risk ambiguous fields) or uglify the dropdown with
an ID number.
Now, this works:
person.org_name => “org: person”
_form.rhtml:
<%= text_field_with_auto_complete :person, :name %>
<%= hidden_field :association, :person_id %> <--- the field I want
populated
_people.rhtml:
<% for person in @people do -%>
<%= h person.org_name %>
<% end -%>
… but ONLY for clicks (and onmouseover). onselect, onkeypress, etc…
do nothing, so it doesn’t work for tab or enter. And I can’t access the
id from after_update_element 'cause the popup is no longer there to get
queried and all I can access is the text field itself and the selected
value (ie the result of person.org_name rather than person.id). (Or can
I? If so I don’t know how. :-/)
Any help?
Also, when I’m using autocomplete in a sub-sub-form the popup doesn’t
show. When it’s just in a form or subform it does, though. And I can
tell it’s getting called 'cause I see it on the log tail. I set
position:absolute; in CSS; anything else that could do it?
That sounds like the text field will display “23,foo,bar”. Which is
rather ugly.
The page you linked to just does the same thing - makes the first field
‘id’; hides it in the dropdown but it’ll be displayed as selected once
something is chosen. Ugly UI. And then it uses that to populate other
fields on the after-update call.
But I’d like a way to reliably populate a hidden field with the hidden
‘id’ part of the popup no matter how selected, and have the text field
just show the prettified name.
‘id’; hides it in the dropdown but it’ll be displayed as selected once
something is chosen. Ugly UI. And then it uses that to populate other
fields on the after-update call.
But I’d like a way to reliably populate a hidden field with the hidden
‘id’ part of the popup no matter how selected, and have the text field
just show the prettified name.
Ok that link does hide the id, which is not the link it was meant to
point to