Hi I am doing the Working with JavaScript in Rails guide, but I get stuck in section
2 Unobtrusive JavaScript
When it says :
pull the function definition out of the click handler, and turn it into CoffeeScript:
paintIt = (element, backgroundColor, textColor) ->
``element.style.backgroundColor = backgroundColor
``if textColor?
``element.style.color = textColor
And then on our page:
<``a
href``=``"#"
onclick``=``"paintIt(this, '#990000')"``>Paint it red</``a``>
When I do this I and click on the link in my chrome browser I get in the javascript console this error.
- Uncaught ReferenceError: paintIt is not defined (index):55
- onclick
Any suggestions please what I am doing wrong.
Thanks