I am using jquery on my html page and want to have an onchange event on a collection_select.
If I add <%= javascript_include_tag :defaults %>
then my jquery code does not work.
Basically I have a collection_select as follows:
<%=collection_select(:product, 'prod_name', @prods, :id, :prod_name,
{:prompt => 'Select Product'},{:onchange => remote_function(:url =>
{:action => 'volume_or_quant'}, :with => "'id=' + this.value")})%>
Then I have a select tag and a text field:
<%=select_tag :volume, options_for_select(["", "1/8 lb", "1/4 lb", "Single",
"Multi 5" ], "N/A") %>
<%= text_field_tag :quantity, "", :size=>"4"%>
When an option is selected from the collection_select
I want to go back to my action and check whether it has volume or unit in the DB. Based on which, the above selectbox/textbox will be enabled.
right now my action looks like:
def volume_or_quant
@product = Product.find(params[:id])
puts "Value: " + @product.volume
end
However, when I select something...nothing happens. Right now I do not have default javascripts.
is what I'm trying to do require the default prototype javascript? or can it be done with jquery?