Alex Rivera | Logout

CoffeeScript function created in app/assets/javascript not found

Asked 2012-07-13T04:18:34.310
24

In my CoffeeScript file, clients.js.coffee,

myFunction = (variable) ->

I created a function in CoffeeScript in app/assets/javascript. But when I try to call that function, the console shows me an error saying function not found.

I check the source of the page and it shows that the script is loaded:

<script src="/assets/clients.js?body=1" type="text/javascript"></script>

This is what was found inside the script source:

(function() {
  var myFunction;

  myFunction = function(variable) {}
}).call(this);

Any idea what am I missing? What should I do to call the function?

Edit
Report

1 Answer

7

Bind it to the window

myFunction = (variable) ->
  alert('zzzzzzzz')

window.myFunction = myFunction
answered 2012-07-13T04:34:09.207

Your Answer