This does not make any sense to me:
I have a model called TypeWell along with it controller and forms. If I
attach a jQuery event Handler using old fashioned Javascript code to its
form partial like shown below:
:javascript
$(document).ready(function() {
$("#type_well_gas_type").change(function() {
alert(“Gas type changed”);
});
});
It alerts the message once (correctly) as shown when I change the
gas_type drop-down. If however, I move this code from the form partial
(app/views/type_wells/_form.haml.html to the corresponding coffeescript
file
app/assets/javascripts/type_wells.js.coffee (of course delete it from
the form partical) as shown below:
$(document).ready ->
$("#type_well_gas_type").change ->
alert “gas type changed”
then it triggers twice instead of once as expected? Note that I have
eliminated the doubt that it might be Coffeescript related by moving the
coffeescript code shown above and attaching it to the form partial
directly instead of putting it in the
app/assets/javascripts/type_wells.js.coffee file, so it is definitely
pipeline related mess.
This is as basic as it gets. Is there something that I do not
understand about asset pipeline that is causing this behavior?
Please explain.
Thanks.
Bharat