A
A
Alexander Grishin2015-11-23 18:43:52
Ruby on Rails
Alexander Grishin, 2015-11-23 18:43:52

How to turn JS code into CoffeeScript in RoR framework?

Hello!
Here is the HTML where it is called:

<div class='list-cart-up-key' onclick="listActions.cartUpKey(this)"></div>
              <div class='list-cart-counter'  >0</div>
              <div class='list-cart-down-key' onclick="listActions.cartDownKey(this)"></

Here is the script:
var listActions = {
  cartUpKey: function(it){
             alert('UP');
  },
  cartDownKey: function(it){
             alert('DOWN');
  }
}

How to turn this case into CoffeeScript?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2015-11-23
@beerdy

listActions =
  cartUpKey: (it) ->
    alert('UP')
  cartDownKey: (it) ->
    alert('DOWN')

For the future - js2.coffee

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question