I''m new to js and rails. I''ve created a page and i''m trying to implement the autocomplete. I do''nt know where the data comes from. The demo says it comes from "/ajax/auto_complete_for_contact_name" - what is that? I downloaded some of the files from scriptaculous and they have a url which is an html file that is in the shape of XML. Where exactly does the info come from that populates the div? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2007-Mar-28 07:20 UTC
Re: autocomplete question - where''s the data?
apparker a écrit :> I''m new to js and rails. I''ve created a page and i''m trying to > implement the autocomplete. I do''nt know where the data comes from. > The demo says it comes from "/ajax/auto_complete_for_contact_name" - > what is that? I downloaded some of the files from scriptaculous and > they have a url which is an html file that is in the shape of XML. > Where exactly does the info come from that populates the div?With Autocompleter.Local, it comes from a JS array in your page. With Ajax.Autocompleter, it is provided by a URL in your app, which takes one parameter (the default name is that of your text field, but can be customized), and produces a <ul>/<li> list of results. It''s all there, with all the necessary details: http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter The wiki also provides you with basic styling for that result, so you obtain a decent aspect. -- 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 -~----------~----~----~----~------~----~------~--~---
I''m still not sure what you mean by the url... the demo page''s source says it is using "/ajax/auto_complete_for_contact_name". What file is this pointing to? It doesn''t have an extension. Do I point it at an XML file? Text file? What format does it have to be in? On Mar 28, 2:20 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> apparker a écrit : > > > I''m new to js and rails. I''ve created a page and i''m trying to > > implement the autocomplete. I do''nt know where the data comes from. > > The demo says it comes from "/ajax/auto_complete_for_contact_name" - > > what is that? I downloaded some of the files from scriptaculous and > > they have a url which is an html file that is in the shape of XML. > > Where exactly does the info come from that populates the div? > > With Autocompleter.Local, it comes from a JS array in your page. > With Ajax.Autocompleter, it is provided by a URL in your app, which > takes one parameter (the default name is that of your text field, but > can be customized), and produces a <ul>/<li> list of results. > > It''s all there, with all the necessary details: > > http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter > > The wiki also provides you with basic styling for that result, so you > obtain a decent aspect. > > -- > Christophe Porteneuve a.k.a. TDD > "[They] did not know it was impossible, so they did it." --Mark Twain > Email: t...-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 -~----------~----~----~----~------~----~------~--~---
Technically, it doesn''t matter what format it''s in. As long as its output is an unordered list you''re good to go. For example, you could use PHP to connect to a database and extract information about contact names and then display them like this: <ul> <li>Doe, Jane</li> <li>Kees, David</li> <li>Smith, John</li> </ul> As long as your output is formatted thusly, the AutoCompleter should do the rest. Therefore, you can use PHP, XML, ColdFusion, HTML, whatever, as long as you have an unordered list when you''re done. -- Dash -- apparker wrote:> I''m still not sure what you mean by the url... the demo page''s source > says it is using "/ajax/auto_complete_for_contact_name". What file is > this pointing to? It doesn''t have an extension. Do I point it at an > XML file? Text file? What format does it have to be in? > > On Mar 28, 2:20 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote: > >> apparker a écrit : >> >> >>> I''m new to js and rails. I''ve created a page and i''m trying to >>> implement the autocomplete. I do''nt know where the data comes from. >>> The demo says it comes from "/ajax/auto_complete_for_contact_name" - >>> what is that? I downloaded some of the files from scriptaculous and >>> they have a url which is an html file that is in the shape of XML. >>> Where exactly does the info come from that populates the div? >>> >> With Autocompleter.Local, it comes from a JS array in your page. >> With Ajax.Autocompleter, it is provided by a URL in your app, which >> takes one parameter (the default name is that of your text field, but >> can be customized), and produces a <ul>/<li> list of results. >> >> It''s all there, with all the necessary details: >> >> http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter >> >> The wiki also provides you with basic styling for that result, so you >> obtain a decent aspect. >> >> -- >> Christophe Porteneuve a.k.a. TDD >> "[They] did not know it was impossible, so they did it." --Mark Twain >> Email: t...-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 -~----------~----~----~----~------~----~------~--~---
So I can use ''getDBresults.php'' as the url which creates an XML output from some SQL query? That''d be cool. Another question, why does the demo page''s source say, "autocomplete="off"? And, the demo page doesn''t have any parameters after the url: type="text/javascript">new Ajax.Autocompleter(''contact_name'', ''contact_name_auto_complete'', ''/ajax/auto_complete_for_contact_name'', {}) How does it know what to do? I''ve copied the contents of the demo into my own page and still cannot get it to work (pointing at a generic unordered list). My page keeps saying "ajax.autocompleter not valid constructor" or something. All of my js files are pointing to the correct places. www.parkereye.com/eye On Mar 28, 7:41 am, David Dashifen Kees <dashi...-NT0ononE2K1Wk0Htik3J/w@public.gmane.org> wrote:> Technically, it doesn''t matter what format it''s in. As long as its > output is an unordered list you''re good to go. For example, you could > use PHP to connect to a database and extract information about contact > names and then display them like this: > > <ul> > <li>Doe, Jane</li> > <li>Kees, David</li> > <li>Smith, John</li> > </ul> > > As long as your output is formatted thusly, the AutoCompleter should do > the rest. Therefore, you can use PHP, XML, ColdFusion, HTML, whatever, > as long as you have an unordered list when you''re done. > > -- Dash -- > > apparker wrote: > > I''m still not sure what you mean by the url... the demo page''s source > > says it is using "/ajax/auto_complete_for_contact_name". What file is > > this pointing to? It doesn''t have an extension. Do I point it at an > > XML file? Text file? What format does it have to be in? > > > On Mar 28, 2:20 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote: > > >> apparker a écrit : > > >>> I''m new to js and rails. I''ve created a page and i''m trying to > >>> implement the autocomplete. I do''nt know where the data comes from. > >>> The demo says it comes from "/ajax/auto_complete_for_contact_name" - > >>> what is that? I downloaded some of the files from scriptaculous and > >>> they have a url which is an html file that is in the shape of XML. > >>> Where exactly does the info come from that populates the div? > > >> With Autocompleter.Local, it comes from a JS array in your page. > >> With Ajax.Autocompleter, it is provided by a URL in your app, which > >> takes one parameter (the default name is that of your text field, but > >> can be customized), and produces a <ul>/<li> list of results. > > >> It''s all there, with all the necessary details: > > >> http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter > > >> The wiki also provides you with basic styling for that result, so you > >> obtain a decent aspect. > > >> -- > >> Christophe Porteneuve a.k.a. TDD > >> "[They] did not know it was impossible, so they did it." --Mark Twain > >> Email: t...-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 -~----------~----~----~----~------~----~------~--~---
Yup. Using a database to store your information for display in a field ... even an AutoCompleter field ... is -- at least in my opinion -- kind of the point of all this AJAX-y stuff. As for why your specific demo doesn''t work, I''m going to leave to someone else because I''m not familiar specifically with how the AutoCompleter works, only with its general purpose. If no one gets back to you, I''ll play around with it later and see what I can figure out. -- Dash -- apparker wrote:> So I can use ''getDBresults.php'' as the url which creates an XML output > from some SQL query? That''d be cool. > > Another question, why does the demo page''s source say, > "autocomplete="off"? > > And, the demo page doesn''t have any parameters after the url: > type="text/javascript">new Ajax.Autocompleter(''contact_name'', > ''contact_name_auto_complete'', ''/ajax/auto_complete_for_contact_name'', > {}) > > How does it know what to do? > > I''ve copied the contents of the demo into my own page and still cannot > get it to work (pointing at a generic unordered list). My page keeps > saying "ajax.autocompleter not valid constructor" or something. All > of my js files are pointing to the correct places. > www.parkereye.com/eye > > > On Mar 28, 7:41 am, David Dashifen Kees <dashi...-NT0ononE2K1Wk0Htik3J/w@public.gmane.org> wrote: > >> Technically, it doesn''t matter what format it''s in. As long as its >> output is an unordered list you''re good to go. For example, you could >> use PHP to connect to a database and extract information about contact >> names and then display them like this: >> >> <ul> >> <li>Doe, Jane</li> >> <li>Kees, David</li> >> <li>Smith, John</li> >> </ul> >> >> As long as your output is formatted thusly, the AutoCompleter should do >> the rest. Therefore, you can use PHP, XML, ColdFusion, HTML, whatever, >> as long as you have an unordered list when you''re done. >> >> -- Dash -- >> >> apparker wrote: >> >>> I''m still not sure what you mean by the url... the demo page''s source >>> says it is using "/ajax/auto_complete_for_contact_name". What file is >>> this pointing to? It doesn''t have an extension. Do I point it at an >>> XML file? Text file? What format does it have to be in? >>> >>> On Mar 28, 2:20 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote: >>> >>>> apparker a écrit : >>>> >>>>> I''m new to js and rails. I''ve created a page and i''m trying to >>>>> implement the autocomplete. I do''nt know where the data comes from. >>>>> The demo says it comes from "/ajax/auto_complete_for_contact_name" - >>>>> what is that? I downloaded some of the files from scriptaculous and >>>>> they have a url which is an html file that is in the shape of XML. >>>>> Where exactly does the info come from that populates the div? >>>>> >>>> With Autocompleter.Local, it comes from a JS array in your page. >>>> With Ajax.Autocompleter, it is provided by a URL in your app, which >>>> takes one parameter (the default name is that of your text field, but >>>> can be customized), and produces a <ul>/<li> list of results. >>>> >>>> It''s all there, with all the necessary details: >>>> >>>> http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter >>>> >>>> The wiki also provides you with basic styling for that result, so you >>>> obtain a decent aspect. >>>> >>>> -- >>>> Christophe Porteneuve a.k.a. TDD >>>> "[They] did not know it was impossible, so they did it." --Mark Twain >>>> Email: t...-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 -~----------~----~----~----~------~----~------~--~---
On Mar 28, 2007, at 8:53 AM, apparker wrote:> Another question, why does the demo page''s source say, > "autocomplete="off"?Autocomplete from the browser messes seriously with this sort of thing, it fights the system by filling in the last thing you typed into a field of that particular name, which may or may not be what you want. The autocomplete functions all submit one character at a time to your server script (unless configured otherwise), which gives the effect of narrowing down the search as you type, shortening the list to only a few really good matches. Browser autocomplete would break that behavior.> > And, the demo page doesn''t have any parameters after the url: > type="text/javascript">new Ajax.Autocompleter(''contact_name'', > ''contact_name_auto_complete'', ''/ajax/auto_complete_for_contact_name'', > {}) > > How does it know what to do?Because it is using the defaults, which are defined as what (I imagine) the developers experience says is the 80% use-case. Have a look in the middle column of the table of available parameters. That shows the default, i.e.: what you get when you don''t pass that parameter at all. Walter --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---