Hi all For a project i am playing around with the Ajax.Autocompleter. It has basicly the functionality i need but with the little difference that i would rather use it as LiveSearch with clickable links instead of auto-completing a inputfield. Any ideas how i can make it so that, if a user selects a result it does not go to the inputfield but the link/result he chooses (either with keyboard+enter or mousclick) will be launched? TIA, Kjell _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> For a project i am playing around with the Ajax.Autocompleter. It has > basicly the functionality i need but with the little difference that i would > rather use it as LiveSearch with clickable links instead of auto-completing > a inputfield. Any ideas how i can make it so that, if a user selects a > result it does not go to the inputfield but the link/result he chooses > (either with keyboard+enter or mousclick) will be launched?> TIA, KjellI''m using: <input type="text" id="busqueda" name="busqueda" /> <div id="busqueda_auto_complete" class="auto_complete" style="display:none"></div> <script type="text/javascript"> function busqueda_eligio(elegido) { url = elegido.getElementsByTagName("span")[0].innerHTML; window.location = url; } new Ajax.Autocompleter("busqueda", "busqueda_auto_complete", "<%= escape_javascript(url_for(:controller => ''buscador'', :action=> ''complete_me'')) -%>", {updateElement: busqueda_eligio, frequency: 0, method: ''get'', onShow: function(element, update){Effect.Appear(update,{duration:0.15});} } ); </script> And in the view that provide the options: <ul> <% @datos.each do |x| -%> <li><span style="display: none"><%= x[1] -%></span><%= x[0] -%></li> <% end -%> </ul> Hope it helps, HoraPe --- Horacio J. Peña horape-Zlwz598M9fGnYQj17FrgxVAUjnlXr6A1@public.gmane.org horape-03kPrFAwsvU3uPMLIKxrzw@public.gmane.org
Thank you! That worked :) Here is my modified non-rails version (for the records): new Ajax.Autocompleter(inputfield, resultfield, baseurl+''search.php'', { method:''get'', frequency:0, updateElement: function(resultItem) { window.location = resultItem.getElementsByTagName (''span'')[0].innerHTML; } }); On 7/1/06, Horacio J. Peña <horape-Zlwz598M9fGnYQj17FrgxVAUjnlXr6A1@public.gmane.org> wrote:> > > For a project i am playing around with the Ajax.Autocompleter. It has > > basicly the functionality i need but with the little difference that i > would > > rather use it as LiveSearch with clickable links instead of > auto-completing > > a inputfield. Any ideas how i can make it so that, if a user selects a > > result it does not go to the inputfield but the link/result he chooses > > (either with keyboard+enter or mousclick) will be launched? > > > TIA, Kjell > > I''m using: > > <input type="text" id="busqueda" name="busqueda" /> > <div id="busqueda_auto_complete" class="auto_complete" > style="display:none"></div> > <script type="text/javascript"> > function busqueda_eligio(elegido) { > url = elegido.getElementsByTagName("span")[0].innerHTML; > window.location = url; > } > new Ajax.Autocompleter("busqueda", "busqueda_auto_complete", > "<%= escape_javascript(url_for(:controller => ''buscador'', > :action=> ''complete_me'')) -%>", > {updateElement: busqueda_eligio, > frequency: 0, > method: ''get'', > onShow: function(element, update){Effect.Appear(update,{duration: > 0.15});} } ); > </script> > > And in the view that provide the options: > > <ul> > <% @datos.each do |x| -%> > <li><span style="display: none"><%= x[1] -%></span><%= x[0] -%></li> > <% end -%> > </ul> > > > Hope it helps, > HoraPe > --- > Horacio J. Peña > horape-Zlwz598M9fGnYQj17FrgxVAUjnlXr6A1@public.gmane.org > horape-03kPrFAwsvU3uPMLIKxrzw@public.gmane.org >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On Saturday 01 July 2006 07:07, Kjell Bublitz wrote:> Hi all > > For a project i am playing around with the Ajax.Autocompleter. It has > basicly the functionality i need but with the little difference that i > would rather use it as LiveSearch with clickable links instead of > auto-completing a inputfield. Any ideas how i can make it so that, if a > user selects a result it does not go to the inputfield but the link/result > he chooses (either with keyboard+enter or mousclick) will be launched?check out what I did for g-p: http://gentoo-portage.com/ The code I wrote is buried deep inside /js/main.js in the Ajax.XMLAutocompleter class. Note that this is *not* a generic class, it''s in fact very very specific :) I may turn it into a more generic class at a later time, but the concept is shown. Mike wanted to be able to return an XML document and have that parsed on the client-side, so I overrode the onComplete method to parse/build the request content myself. Unfortunately, it expects the text of the content for the drop down rather than the DOM node to append, but, meh, innerHTML *does* perform faster on *every* browser than DOM manipulation, sadly ;) -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org http://www.pirate-party.us/ -- defend your rights _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Heya, Just wanted to note that it seems it has some graphical glitches on Safari, most notably the "type" thing at the right side of the list (Package, etc.) disappears when you mouseover. Best, Thomas Am 03.07.2006 um 18:49 schrieb Jeremy Kitchen:> check out what I did for g-p: > http://gentoo-portage.com/ > > The code I wrote is buried deep inside /js/main.js in the > Ajax.XMLAutocompleter class. Note that this is *not* a generic > class, it''s > in fact very very specific :) I may turn it into a more generic > class at a > later time, but the concept is shown. > > Mike wanted to be able to return an XML document and have that > parsed on the > client-side, so I overrode the onComplete method to parse/build the > request > content myself. > > Unfortunately, it expects the text of the content for the drop down > rather > than the DOM node to append, but, meh, innerHTML *does* perform > faster on > *every* browser than DOM manipulation, sadly ;) > > -Jeremy >