Hi, 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ß Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Xavier Noria
2007-Mar-15 23:56 UTC
Re: Autocomplete for the chosen element from autocomplete
On Mar 15, 2007, at 1:07 AM, Any Dot wrote:> 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.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. -- fxn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > 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. > > -- fxnCan 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Xavier Noria
2007-Mar-25 10:29 UTC
Re: Autocomplete for the chosen element from autocomplete
On Mar 24, 2007, at 9:34 PM, psyber wrote:>> 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. >> >> -- fxn > > > 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 And then: <%= some_auto_completion_helper ..., :after_update_element => after_update_element_js %> Behind /foo/bar there''s a RJS that updates the second widget from params[:value]. -- fxn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---