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 <
[EMAIL PROTECTED]> 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 = ""> 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
[EMAIL PROTECTED]
[EMAIL PROTECTED]
_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs