Hi all,
Been trying to fix this for a while now. Been searching but have not
found anything related documented. Surprised that noone else seems to
have encountered this problem. I am trying to implement Autocomplete
in one of my forms and although its working in FF, not in Safari. This
is the work-flow I am talking about.
1.User starts typing
2.Autocomplete kicks off and returns matching strings in relevant
attributes and Model.
3.User scrolls down options and selects the one he/she wants.
4.Selected option appears on the text box
4a.Text appearing in text box may be different from that shown to
user in options list. Like in the Scriptaculous
customised_autocomplete demo.
5.When the form is submitted -> The autocomplete field may be either a
virtual attribute or otherwise. The field is for a belongs_to
associated model so ultimately, the foreign key must be set (in my
case, its contact_id for a Create/Edit Reminder form).
Safari breaks in Step 4 ie. the selected option does not appear in the
text box, and does not get submitted with the rest of the form. I have
tried using the auto_complete plugin for this as well as the
Scriptaculous methods. Both break at the same step in Safari. An
observation here if its any help - the blue focus outline for the
field is slightly eaten up on the bottom side of the field as though
there is something on top of it. This is after I select an option from
the list.
I am also not able to figure out how to achieve steps 4a and 5. Here
is the code I have so far.
_reminder.html.erb
<%= text_field_with_auto_complete :reminder, :contact_id,
{}, :skip_style => false %><br/>
...
reminders_controller.rb
Code : - fold - unfold
protect_from_forgery :except =>
[:auto_complete_for_reminder_contact_id]
def auto_complete_for_reminder_contact_id
auto_complete_responder_for_contacts params[:reminder]
[:contact_id]
end
...
private
def auto_complete_responder_for_contacts(value)
@contacts = current_user.contacts.find(:all,
:conditions => [ 'LOWER(name) LIKE ? OR LOWER(email) LIKE ?',
'%' + value.downcase + '%','%' + value.downcase + '%' ],
:order => 'name ASC',
:limit => 8)
render :partial => 'list'
end
...
_list.html.erb
<ul>
<%- for contact in @contacts do -%>
<li>
<div><%=h contact.name %></div>|<div><%=h contact.email %></div>|
<div><%=h contact.company.name %></div>
</li>
<%- end -%>
</ul>
Hope someone's got pointers. Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---