Using coffeescript, jQuery, and sprockets in rails 3.1 the coffeescript files are compiled in to blocks like:
(function() {
var a;
var b;
var c;
foo = function() {
alert("foo");
}
bar = function() {
alert("bar");
}
}).call(this);
This seems to move functions foo and bar out of global scope, so bar can be called by foo, but neither can be called from the html code. When I try to call foo from a select onchange element, I get a "Can't find variable: foo".
The workaround right now is to move all globally available functions to .js files. But what's the right way to do this?
Thanks