This coffee script code
class TestCoffee
constructor: (@saludo) ->
helloCoffee: ->
alert @saludo+" Coffee v7"
is generating the following javascript with mindscape web workbench 2.0.332.18684
(function() {
var TestCoffee;
TestCoffee = (function() {
function TestCoffee(saludo) {
this.saludo = saludo;
}
TestCoffee.prototype.helloCoffee = function() {
return alert(this.saludo + " Coffee v7");
};
return TestCoffee;
})();
}).call(this);
How should I use this code inside my asp.net mvc 3 view?
I’m importing the js code with
<script src="@Url.Content("~/Scripts/helloCoffe.js")" type="text/javascript"></script>
and trying to use with
<script type="text/javascript">
$(document).ready(function () {
var coffee;
coffee = TestCoffee("Jelouuuu");
coffee.helloCoffee();
});
</script>
I got a TestCoffee undefined error
So, how should I use it?
Thanks In Advance!
This is by design:
http://jashkenas.github.com/coffee-script/
I normally use jQuery $.extend to push a function into the jquery namespace for other scripts to use.
IE:
file1.coffee
file2.coffee