In fact, everything works as intended. As you can read here , Coffeescript wraps your code with an anonymous function to prevent pollution of the global namespace. If you just look at the examples, you can skip this, but the docs clearly state:
Although suppressed in this documentation for clarity, all CoffeeScript Outputs are wrapped in an anonymous function: (function () {...}) (); This protective shell, combined with the automatic generation of the var keyword, makes it extremely difficult to contaminate the global namespace by accident.
In order to access an object, variable or method declared in this artificial scope, you will need to make this explicitly available in the global scope, for example. eg:
window.validate_signup_form = validate_signup_form
In the case you mention, I would definitely use events to trigger the method.
Btw: There is no need for an empty bracket in the declaration of your method foo =-> works fine.
source share