I have CoffeeScript that looks like the following:
myfunctionname = (foo, bar, baz) ->
alert("I am here")
return
This is supposed to be the way to declare a function in coffee script. (according to js2coffee.org and others)
This gets converted into the following:
(function() {
var myfunctionname;
myfunctionname = function(foo, bar, baz) {
alert("I am here");
};
}).call(this);
The problem with this is that when I try to include this js file into a view and access my myfunctionname
method, it does not exist. It is probably out of scope.
Thus, CoffeeScript does not convert into a usable format for me. I need the following output format:
function myfunctionname (foo, bar, baz) {
alert("I am here");
};
This format allows me to include the functions where I need them.
Is there any way of achieving this in CoffeeScript? Or should I consider dropping CoffeeScript altogether?