问题
I have two files: first one is a plain jQuery, and a second one is a Coffeescript
jQuery file:
$(document).ready(function(){
checkPrice();
});
CoffeeScript file:
$ ->
checkPrice = ->
alert("OK");
I get following error: "Unhandled Error: Undefined variable: checkPrice"
In the template they are included in opposite direction: coffeescript file, then jquery file.
Is there some way to make them working together ?
回答1:
OK. Got it.
checkPrice should have been declared as global, so in coffeescript file I have:
window.checkPrice =->
alert("OK");
And now it works!
Thank's everyone who was there to help me anyway.
来源:https://stackoverflow.com/questions/13604175/call-coffeescript-function-from-jquery-function