The coffeescript compiler is, for some reason, wrapping all of my .coffee files in a function when they are compiled. For example, if I have test.coffee:
cla
See my answer here on sharing jS code between files/modules. Also FYI the wrapper function is by design to prevent unintentional global variables. You can disable with by passing --bare
to the coffee compiler command line tool, but it is a best practice with good reason.
Never add event listeners in HTML. Add them in your JavaScript, preferably in the same scope in which you define the event handler.
printAValue = () ->
test = new TestClass()
test.printValue()
document.body.addEventListener('load', printAValue, false)
If you absolutely need to export something to the global scope, export to the window object:
window.printAValue = () ->
test = new TestClass()
test.printValue()