I am starting with rails and coffeescript, but I am having a strange issue now. I would like to create a function called log, which I created like this in my .coffee:
log = (message) -> console.log message
It it translated to js like this:
(function() {
var log;
log = function(message) {
return console.log(message);
};
log('Podcast downloader 2000');
}).call(this);
If I call the function as I am calling in the example, it works. but now I want to call it using a onclick="log('avb')
<span onclick="log('abc')"/>
but the function is not on the right scope, so it doesn't get called.
How do I change my code so I can call the function from the onclick attribute?
thanks!