Wierd issues with autocomplete and prototype

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) %>

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?

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.