0

In this tutorial it includes the code:

jQuery(function($) {
    // do stuff ...
});

How do I write this in CoffeeScript? jQuery($) -> isn't right, but I can't work out what is.

2 Answers 2

2

You have to add a space after jQuery to make an anonymous function with $ as its only argument:

jQuery ($) ->
    foo();

And the result:

jQuery(function($) {
  return foo();
});
Sign up to request clarification or add additional context in comments.

Comments

2

If I remember right, just like this: $ ->

1 Comment

This potentially works too, but it isn't the same as the code the OP posted since he make have jQuery in noConflict mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.