Take the 2-minute tour ×  In JS I have    click : function() {
// do something useful with $(this)....}  How I can describe
this with CoffeeScript?  share|improve this question  3 Answers
3  It's almost the same:  $("#index").on click: ->   alert
("hi") , "li.superclass" share|improve this answer Too many
brackets! Get rid of the superfluous cruft from your code ,~) – 
Billy Moon Sep 20 '12 at 13:30 I don't think you can avoid the
brackets around the selector, otherwise the .on tries to operate
on the string of the selector itself. –  Billy Moon Sep 20 '12
at 13:34 I would probably do it in two statements, caching the
jquery object (usually a good idea anyway): $index = $ "#index";
$index.on click: -> alert "hi", "li.superclass" –  Billy Moon
Sep 20 '12 at 13:35 @BillyMoon: Ah, yes, you're absolutely
right. –  João Silva Sep 20 '12 at 13:37  mybe this is you want:
alert "hi"  but i think this is more clear:  events =
alert "hi" $("#index").on events, "li.superclass" share|improve
this answer