0

I have a Rails app with a CoffeeScript file. The Rails Asset Pipeline compiles it into a JavaScript file.

I'd like to open up the Chrome Developer Tools JavaScript Console and execute functions defined in my .coffee file.

However in the compiled JS it's all wrapped up like this...

(function() {

  var youLot = function() {
    return "Wot?";
  };

}).call(this);

So what happens in the JS console...

youLot();
ReferenceError: youLot is not defined

Without going through too many contortions, is there a way I can call youLot() in the Chrome JS console even though I originally declared it in a CoffeeScript file?

Ethan
  • 57,819
  • 63
  • 187
  • 237

1 Answers1

0

I think you want:

window.myVariable

But, I recommend you read up on coffee scripts handling of scope. SO reference

Community
  • 1
  • 1
TheIrishGuy
  • 2,531
  • 19
  • 23