I'm developing a rails application for school and I can't figure out why these events never get triggered. This is only my second time using coffeescript. The first time was on this same app and it works great. I've searched around on stackoverflow and looked at the jquery API but I can't figure out where I'm going wrong? I even tried changing the <input>
tag in question to a <span>
and the event to "click"
. That is the exact setup I have for my other piece of coffeescript(which works)... But here it doesn't work. I haven't even started the functionality I'm aiming for. This is just a sanity check that isn't going so well.
[assets/javascripts/calculator.coffee]
$ ->
$("#foot_count").on("keyup change paste", update)
update = ->
console.log("askhdkajshk")
[views/site/calculator.html.erb]
<div id="main">
<div class="large_main_container">
<h1>Fill out this form to get a rough estimate.</h1>
<form>
<table>
<tr>
<td class="form_label">Number of Feet</td>
<td><input class="input_field" id="foot_count" type="text"></td>
</tr>
<tr>
<td class="form_label">Number of Gates</td>
<td><input class="input_field" id="gate_count" type="text"></td>
</tr>
<tr>
<td class="form_label">Estimated Price</td>
<td id="calculated_value">Some Value</td>
</tr>
</table>
</form>
</div>
</div>
Update My problem was rendering the page with :layout => false. I'm not really sure where in assets to put this coffeescript. Time to start reading. If anyone has advice, thanks!
Update
Addding <%= javascript_include_tag "application" %>
to my view solved the problem.