Forum: Ruby on Rails Wierd issues with autocomplete and prototype

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
20d3bd6cbf48e65ad66ec03ef82460d1?d=identicon&s=25 flip (Guest)
on 2007-03-18 15:31
(Received via mailing list)
I have been trying to figure out an issue that I have run in to for
the last couple of days. I am using autocomplete in a few areas in my
project to pull up a list of things when adding something that has a
relationship so that a user doesn't create duplicates. In some cases
the fields for those objects are being added to the form after a user
clicks on a add thing link and in other cases the fields are being
built when the page loads. The issue I am having is that if I use the
exact same code for the fields it works when I add the fields after
the form has been generated via ajax but doesn't work when the fields
are present on page load. I am running on edge rails and here is an
example of the code being used:

<%= text_field_tag("publisher_name", nil, {:size => 30, :class =>
"inputText"}) %>
<%= auto_complete_field("publisher_name", :url =>
auto_complete_publishers_path, :method => :get) %>
<div class="auto_complete" id="publisher_name_auto_complete"></div>

Basically I am using a custom auto complete function and my app is
REST based. I have routes set up and as I mentioned everything works
as advertised in one case but not the other.

When I add the field on page load of the form I get the following
error from prototype:

hide(null)prototype.js (line 1153)
baseInitialize("publisher_name", "publisher_name_auto_complete",
Object paramName=publisher_name tokens=[0] frequency=0.4)controls.js
(line 84)
initialize("publisher_name", "publisher_name_auto_complete", "/
publishers;auto_complete", Object paramName=publisher_name tokens=[0]
frequency=0.4)controls.js (line 335)
create()prototype.js (line 23)
[Break on this error] $(element).style.display = 'none';

Any one have any idea what is going on?
20d3bd6cbf48e65ad66ec03ef82460d1?d=identicon&s=25 flip (Guest)
on 2007-03-18 16:11
(Received via mailing list)
Well I feel dumb. On a whim I decided to move the auto_complete_field
tag to below the div it is set to update and everything works
correctly. Guess I didn't try everything I could think of till this
morning.
This topic is locked and can not be replied to.