I have a Rails 4 application with some Coffeescript that is mostly used to update lists upon selection of an item in another list - pretty basic stuff.
The script works perfectly in development. However, as soon as it is precompiled, even though I see the actual code in the precompiled asset file, it will not run at all.
I reduced the code to a very minimal scope, so all it does is display an alert if a combo box is changed and still not working. I also removed all .coffee files from the assets/javascript directory to only leave this one Coffeescript file and the application.js file to ensure there are no conflicts with other .coffee files.
I also had suspicion about turbolinks, which I then removed and still no change.
application.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require_tree .
attendance.coffee
$('#season_id').on "change", ->
alert('Success!')
The form from app/views/attendances/_form.html.erb
<div class="container">
<form action="/attendances/get_attendance_sheet" accept-charset="UTF-8" data-remote="true" method="post"><input name="utf8" type="hidden" value="✓" /> <table class="table">
<tr>
<td>Saison:</td>
<td><select name="season_id" id="season_id" class="form-control"><option value="">Choisir une saison</option><option value="1">Gadbois 2015</option></select></td>
<td>Entraînement du:</td>
<td><select name="session_id" id="session_id" class="form-control"><option value="">Choisir une date d'entraînement</option><option value=""></option></select></td>
<td><input type="submit" name="commit" value="Ouvrir" class="btn btn-success" /></td>
</tr>
</table>
</form></div>
$(document).on 'change', '#season_id', -> alert 'Success'?