Hello,
I''ve looked at a few autocompleters, and really like
Script.aculo.us''.
I have two suggestions for making it even better:
1) Make the default HTTP method GET, or at least clearly document how
to change it (through the prototype options). This will make it
possible for the browser as well as intermediaries to cache the
results.
2) Make it easier to control the URIs that it uses; right now, you can
only put the phrase in a query string, which makes it difficult to
serve autocomplete content from static files; putting it in the query
string pretty much forces people to use a script, which brings higher
server load and more latency.
One way to do this is to use a "URI template" instead of a URI in
Ajax.Autocompleter''s arguments; e.g.,
Ajax.Autocompleter("suggest", "suggest_choices",
"/suggest/{query}");
This way, people can put the query anywhere in the URI that they want,
rather than forcing them to adopt a particular implementation strategy.
The nice thing about this is that the code is really easy;
expand_uri: function (uri, params) {
var vars = uri.match(/{[^}]+}/g);
if (! vars) return uri;
for (var v=0; v < vars.length; v++) {
var name = /{([^}]+)}/.exec(vars[v])[1];
var value = params[name];
var search = new RegExp("{" + name + "}");
uri = uri.replace(search, value);
}
return uri;
}
and because {brackets} aren''t legal in URIs, you can even layer this
into the current Ajax.Autocompleter API without breaking backwards
compatibility.
I talk a bit more about it here
http://www.mnot.net/blog/2006/08/14/webizing_ajax
(I wrote that before I realised there was a place for discussion!)
and I''ve got a sample implementation (in a different namespace) here:
http://www.mnot.net/javascript/http_autocomplete.js
but I''d rather not maintain a separate code base.
Any chance of doing this in the next version of Script.aculo.us?
Thanks and keep up the great 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
-~----------~----~----~----~------~----~------~--~---