Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery "on" and Coffeescript

In JS I have

$("#index").on({
  click : function() { // do something useful with $(this)....}
},"li.superclass");

How I can describe this with CoffeeScript?

like image 225
Vladislav Avatar asked Sep 20 '12 10:09

Vladislav


People also ask

Is CoffeeScript obsolete?

In summary, CoffeeScript began as a fantastic idea (making it easier to write JavaScript code) ultimately, however, it did not stand the test of time and was pushed out by JavaScript and currently, hardly anyone remembers about it.

Is CoffeeScript same as JavaScript?

CoffeeScript is a lightweight language that compiles into JavaScript. It provides simple and easy-to-learn syntax avoiding the complex syntax of JavaScript. CoffeeScript is influenced by JavaScript, Ruby, YAML, Haskell, Perl, Python and has influenced MoonScript, LiveScript, and JavaScript.

What is the point of CoffeeScript?

Advantages of CoffeeScript Using CoffeeScript, we can write clean, clear, and easily understandable codes. Write less do more − For a huge code in JavaScript, we need comparatively very less number of lines of CoffeeScript. Reliable − CoffeeScript is a safe and reliable programming language to write dynamic programs.

Is CoffeeScript easy to learn?

Easy to Understand: The syntax of this language is a simple form of JavaScript. The simplicity of the syntax is the beauty of this programming language. The code written in CoffeeScript is very clean and easily understood.


1 Answers

It's almost the same:

$("#index").on click: ->
  alert ("hi")
, "li.superclass"
like image 139
João Silva Avatar answered Oct 02 '22 22:10

João Silva