How do you pass the selected value to the function? new Ajax.Autocompleter(''text'', ''auto'', ''file'', {paramName:''autocomplete'', updateElement:sayhi}); function sayhi(???){ alert(???); } I''ve tried element and element.value but that didn''t work. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
frank a écrit :> How do you pass the selected value to the function? > > new Ajax.Autocompleter(''text'', ''auto'', ''file'', > {paramName:''autocomplete'', updateElement:sayhi});Don''t you use updateElement! This will *replace* the whole text completion logic that script.aculo.us provides for your text field! Use the afterUpdateElement option. It gets passed two arguments: the auto-completed field, and the <li> that got selected. Have a look at script.aculo.us'' source code (controls.js, around line 250) for clues as to how to play with this <li> to extract data. -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
A peek at the docs (http://wiki.script.aculo.us/scriptaculous/show/ Ajax.Autocompleter) show the parameter is the selected list element: an <li> tag. Element.value wouldn''t work--it doesn''t mean anything to a list element. If that doesn''t work, tell us what version of Scriptaculous you''re using, and which brower. The Scriptaculous source is pretty straightforward about calling your custom function with the selected element passed. Don''t be afraid to dive into the source. function sayhi (el) { alert (el +'' : ''+el.innerHTML); } TAG On Feb 16, 2007, at 5:02 PM, frank wrote:> > How do you pass the selected value to the function? > > new Ajax.Autocompleter(''text'', ''auto'', ''file'', > {paramName:''autocomplete'', updateElement:sayhi}); > > function sayhi(???){ > alert(???); > } > > I''ve tried element and element.value but that didn''t work. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---