Before we can start playing with jQuery and CoffeeScript, let's talk about how you go about writing CoffeeScript code that runs in the browser.
The most common way of compiling CoffeeScript for a web application is to run the coffee
command to watch one or more CoffeeScript files for changes and then to compile them to JavaScript. The output will then be included in your web application.
As an example, we'll organize our project folder structure to look something like the following folder structure:
'
The src folder is where your CoffeeScript files would go. We could then start a CoffeeScript compiler to watch that folder and compile the JavaScript to our public/js folder.
This is what the CoffeeScript command would look like:
coffee -co public/js -w src/
Keep this command running in the background in its own terminal window and it will recompile your CoffeeScript files when you save them.