How could I achieve the following - I have autocomplete which is working
pretty well, but after select any value from the list, I would like to
get in the search box another list of values associated with already
chosen value from the first list and to have autocomplete for the new
list of values? Actually, something like Google suggest functionality
(no, I am not going to launch Google suggest competition smile ), but I
would like to learn and eventually to implement something similar
locally for my web site.
For instance, if I have autocomplete list with dog races and choose
‘terrier’ from the list, I would like to get a new list with - let say
people who have terriers or something like this.
Are there any articles/howto’s which could give the right
comprehending/directionß
For instance, if I have autocomplete list with dog races and choose
‘terrier’ from the list, I would like to get a new list with - let say
people who have terriers or something like this.
There is a completion option called “:after_update_element”. You can
assign there a callback
function (e, v) { … }
and generate a second widget based on the value in its body.
Can anyone offer some sample code on how to do this. I am a perl guru
but when it comes to javascript I’m a weenie.
Sure.
That parameter is a JavaScript function that receives two arguments.
You can just build an ad-hoc anonymous subroutine for it, the
following construction is the JavaScript analogous of sub { … } in
Perl:
this is a Ruby string that contains JavaScript to be passed
to the helper, off the top of my head, untested
after_update_element_js = <<-JS.gsub(/\s+/, ’ ‘)
function(e, v) {
new Ajax.Request(’/foo/bar’, {
parameters: {value: e.value}, /* e.value is the completion */
asynchronous: true,
evalScripts: true
});
}
JS