Soichi Ishida
2012-Dec-06 03:26 UTC
passing parameter from one autocomplete-jquery to another
Rails 3.1.3 My app has two consecutive rails3-autocomplete-jquery form_tags https://github.com/crowdint/rails3-jquery-autocomplete I want to pass a parameter, which depends on the first autocomplete_field_tag choice, to the second. The second form should search based on the parameter. <%= autocomplete_field_tag :departure_id, '''', autocomplete_city_name_plans_path, :size => 75, ''data-delimiter'' => '' '' %> <%= autocomplete_field_tag :destination_id, '''', autocomplete_destination_name_plans_path, :size => 75, ''data-delimiter'' => '' '' %> They are defined in routes.rb resources :plans do get :autocomplete_city_name, :on => :collection get :autocomplete_destination_name, :on => :collection end I tried using jquery $(''#departure_id'').bind(''railsAutocomplete.select'', function(event, data){ departure = data.item.id; if(departure == "") departure="0"; jQuery.get(''/plans/update_destination_select/'' + departure, function(data2){ ... }); can pass a value to an action in plans_controller.rb def update_destination_select departure = City.find_by_id(params[:id]) unless params[:id].blank? @temp_departure_id = departure.id ... end But the class variable @temp_departure_id does not work. Is there anyway to pass a value from the first autocomplete-jquery to another? soichi -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.