I have this in my /assets/javascripts/leads.js.coffee
jQuery ->
getRowColour = (status) ->
switch status
when "rejected" then return '#FFA500'
when "confirmed" then return '#C0C0C0'
when "didn't connect" then return '#90EE90'
else return '#FFFFFF'
and this in my /views/leads/index.html.erb
<%= f.select(:status, ["to call","didn't connect","confirmed","rejected"], {:selected => lead.status}, :onchange => "$('#lead_form_#{lead.id}').submit();document.getElementById('lead_row_#{lead.id}').style.backgroundColor=getRowColour(#{lead.status});") %>
<% end %>
As can be seen my onchange function in f.select has a javascript which calls the function in my coffeescript file.
Please tell me where I am going wrong?