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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedDec 6, '12 at 3:27a
activeDec 6, '12 at 3:27a
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Soichi Ishida: 1 post

People

Translate

site design / logo © 2022 Grokbase