Open individual
2007-Oct-23 13:11 UTC
Passing value such as record[colour] into new Ajax.Autocompleter(...) causes issues!
Hi Everyone, After lots of research and development I got my Auto Complete working with the Active Scaffold plugin on a full _form.rhtml override. I have one last problem that needs to be addressed. I have an an element in the form like this. #################################################################### <input type="text" value="<%= @record.colour %>" size="15" maxlength="15" name="record[colour]" id="record_colour" class="colour- input text-input" autocomplete="on"/> #################################################################### Which conforms to the naming conventions of ActiveScaffold and sends data through upon create / update. Just in case you are wondering I have to follow these attribute naming conventions for the create/edit/update form to work. eg name="record[colour]" id="record_colour" I can not deviate at all otherwise the entire scaffolding system will not work. I also have a AutoComplete javascript function working but then it is difficult to send through the "record[colour]" value with the AJAX method. Here is what the AJAX call looks like. #################################################################### <script type="text/javascript"> //<![CDATA[ var colour_results new Ajax.Autocompleter(''record[colour]'', ''colour_results'', ''/products/ autocomplete'', {method:''get''}) //]]> </script> #################################################################### It says then that the element does not exist and I know it is caused by "record[colour]" I have the following error. #################################################################### this.element has no properties baseInitialize("record[colour]", "colour_results", Object)controls.js (line 57) initialize("record[colour]", "colour_results", "/products/ autocomplete", Object)controls.js (line 402) create()prototype.js (line 23) evalScripts("\n//<![CDATA[\nnew Autocompleter.Local(''record[colour]'', \n ''colour_results'',\n ''/products/autocomp...")prototype.js (line 212) collect("\n//<![CDATA[\nnew Autocompleter.Local(''record[colour]'',\n ''colour_results'',\n ''/products/autocomp...", 1)prototype.js (line 367) (no name)("\n//<![CDATA[\nnew Autocompleter.Local(''record[colour]'',\n ''colour_results'',\n ''/products/autocomp...")prototype.js (line 328) _each(function())prototype.js (line 541) each(function())prototype.js (line 326) collect(function())prototype.js (line 366) evalScripts()prototype.js (line 212) (no name)()prototype.js (line 1643) [Break on this error] this.options.paramName = this.options.paramName || this.element.name; #################################################################### It is caused by the naming convention of Active Scaffold.because if I change the input tag for ...name="record[colour]"... to this ...name="colour"... and the AJAX call from "new Ajax.Autocompleter(''record[colour]'', ..." to "new Ajax.Autocompleter(''colour'',..." then my auto complete receives the correct value and the drop down works but then the create/update does not work as the input name attribute is not following AS conventions. This might become a huge problem as any other AJAX calls follow the same naming convention and will now not work. Can anyone please help me or point out perhaps a mistake or better way. Is there a way basically to get "record[colour]" accepted by an AJAX method, as changing the name to "colour" won''t work with Active Scaffold. Thanks to anyone for any help. I really appreciate it. Uncle Mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---