[Rails-spinoffs] Can Ajax.Autocompleter be abused for this?
Kjell Bublitz
m3nt0r.de at gmail.com
Sat Jul 1 14:50:26 GMT 2006
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 at compendium.com.ar> 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 at compendium.com.ar
> horape at uninet.edu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails-spinoffs/attachments/20060701/92a175be/attachment.html
More information about the Rails-spinoffs
mailing list