Hi,
I am trying to observe a select_tag’s value, and insert a partial inside the page based on that value. Here’s the code:
#index.html.erb
<% form_tag do %>
<%= select_tag ‘product_id’, options_from_collection_for_select(@products, ‘id’, ‘pro_name’), {:id => ‘product_id’} %>
<%= select_tag ‘taxation_id’, options_from_collection_for_select(@taxations, ‘id’, ‘tax_name’), {:id => ‘taxation_id’} %>
<%= observe_field ‘product_id’, :url => {:controller => ‘regulations’, :action => ‘show’}, :with => “‘id=’ + value” %>
<% end %>
#regulations_controller.rb
def show
@regulation = Regulation.find_by_product_id params[:id]
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @regulation }
format.js
end
end
#show.js.rjs
page.alert(“you are here!”)
page.insert_html :bottom, ‘regulations’, :partial => ‘all’, :locals => { :regs => @regulations }
Index.html looks like this:
Is something missing or wrong in the above code? even the alert is not getting called.
Regards