11

I start like I usually do in javascript, so:

$(document).ready ->

but when I save I get a document is not defined. So far I haven't been able to find how to make it work.

Edit: by save, I meant I was using coffee -w. The error was due to me forgetting to use the -c option.

Phrodo_00
  • 444
  • 1
  • 5
  • 11

1 Answers1

18

CoffeeScript is compiled into JavaScript. I'm not sure what you're trying, but in your exact case your CoffeeScript isn't going to look a whole lot different than your JavaScript. Try:

$(document).ready -> alert 'blah'

If that doesn't work, just do a test like

alert document.title

if that doesn't work, I'm going to suggest that you're not running this code inside a browser ;)

kelloti
  • 8,705
  • 5
  • 46
  • 82
  • 4
    thanks for this, it allowed me to see where I was wrong and it's pretty stupid. Apparently, I wasn't trying to actually compile the code, just to run it, since I had forgot to throw in the -c option, now everything is working :) – Phrodo_00 Feb 02 '11 at 23:54