Skip to content

Instantly share code, notes, and snippets.

@truonglocbinh
Created November 18, 2015 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save truonglocbinh/e28b75bc713340accc9c to your computer and use it in GitHub Desktop.
Save truonglocbinh/e28b75bc713340accc9c to your computer and use it in GitHub Desktop.
coffee scripts can not run in rails
$ ->
$("a[data-background-color]").click(e) ->
e.preventDefault()
backgroundColor = $(this).data("background-color")
textColor = $(this).data("text-color")
paintIt(this, backgroundColor, textColor)
<a href="#" data-background-color="#990000">Paint it red</a>
<a href="#" data-background-color="#009900" data-text-color="‪#‎FFFFFF‬">Paint it green</a>
<a href="#" data-background-color="#000099" data-text-color="#FFFFFF">Paint it blue</a>
@thatrubylove
Copy link

The indentation is all wrong

$("a[data-background-color]").click(e) ->
  e.preventDefault()
  console.debug $(this)
  backgroundColor = $(this).data("background-color")
  paintIt(this, backgroundColor, textColor)

@truonglocbinh
Copy link
Author

I copy from rails tutorial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment