When I upgraded to 1.0, I broke autocomplete on a field. I''ve done everything that I can think of to fix the problem, but nothing has worked. I''m able to recreate a simple autocomplete from examples on the various tutorials, but my original code just will not work. <input id="incident_first_party_name" name="incident[first_party_name]" size="30" type="text" value="" /><div class="auto_complete" id="incident_first_party_name_auto_complete"></div><script type="text/javascript"> //<![CDATA[ new Ajax.Autocompleter(''incident_first_party_name'', ''incident_first_party_name_auto_complete'', ''/incidents/auto_complete_for_incident_first_party_name'', {}) //]]> </script> The only thing that stands out to me is the //<![CDATA[ tag. Any ideas? Thanks! -- Posted via http://www.ruby-forum.com/.
On Mon, 2006-03-13 at 18:20 +0100, John Cabrer wrote:> When I upgraded to 1.0, I broke autocomplete on a field. I''ve done > everything that I can think of to fix the problem, but nothing has > worked. I''m able to recreate a simple autocomplete from examples on the > various tutorials, but my original code just will not work. > > <input id="incident_first_party_name" name="incident[first_party_name]" > size="30" type="text" value="" /><div class="auto_complete" > id="incident_first_party_name_auto_complete"></div><script > type="text/javascript"> > //<![CDATA[ > new Ajax.Autocompleter(''incident_first_party_name'', > ''incident_first_party_name_auto_complete'', > ''/incidents/auto_complete_for_incident_first_party_name'', {}) > //]]> > </script> > > The only thing that stands out to me is the //<![CDATA[ tag. > > Any ideas? >---- rather than try to incorporate bits of js code within your objects, why not just load the javascript at the top of your view_code_file or layout_file completely? i.e. <%= javascript_include_tag :defaults %> after which, all I need to do to use autocomplete is a simple definition... <%= text_field_with_auto_complete :placement, :cmwholename, {} %> and of course, have the necessary code in the controller to handle it. Craig
John Cabrer
2006-Mar-13 18:23 UTC
[Rails] Re: Autocomplete broken after update to Rails 1.0
> rather than try to incorporate bits of js code within your objects, why > not just load the javascript at the top of your view_code_file or > layout_file completely? > > i.e. > > <%= javascript_include_tag :defaults %> > > after which, all I need to do to use autocomplete is a simple > definition... > > <%= text_field_with_auto_complete :placement, :cmwholename, {} %> > > and of course, have the necessary code in the controller to handle it. > > CraigThat is what I''ve done. What I pasted above is the resulting code generated and sent to the browser. I have the following in a file called _form.rhtml generated from a scaffold and further modified. <%= text_field_with_auto_complete :incident, :first_party_name %></p> The thing is this worked fine before. Now I don''t even get an error in the JS console. -- Posted via http://www.ruby-forum.com/.