I have two dropdowns in a view, and I\'m attempting to update the second dropdown options based on the selected value from the first dropdown.
I am aware of the Railscas
Add escape_javascript
to escape carrier returns, single and double quotes that get generated by options_from_collection_for_select
.
I do not see any other problems except adding call to escape_javascript
. Please try the following in your js.erb:
<% if @filterProducts %>
$('#product_id').html("<%= escape_javascript options_from_collection_for_select(@products, :id, :name) %>");
<% end %>