I am trying to pass data from my haml views to javascript. In my welcome controller I have index method. In my index.html.haml view file I have the below:
:javascript
window.putalert = "#{ "Data" }";
and in my welcome.js.coffee I have:
jQuery ->
alert putalert
However, the above is not working. I am getting Uncaught ReferenceError: putalert is not defined.
Any suggestions on how to solve this?
The error message in chrome debugging is
(function() {
jQuery(function() {
return alert(putalert);
Uncaught ReferenceError: putalert is not defined
});
}).call(this);