I have the following in a Rails app:
# projects.js.coffee
jQuery ->
$('#project_title').typing ->
start: (event, element) ->
element.css 'background', '#fa0'
stop: (event, element) ->
element.css 'background', '#f00'
alert 'send request to populate samples'
delay: 400
However, in the compiled js file I’m getting the following:
(function() {
jQuery(function() {
return $('#sprinkler_word').typing(function() {
({
start: function(event, element) {
return element.css('background', '#fa0');
},
stop: function(event, element) {
return element.css('background', '#f00');
}
});
alert('send request to populate sprinkle samples');
return {
delay: 400
};
});
});
}).call(this);
Why is the “alert” call not being included in the “stop” function? I assume my syntax is incorrect, but I can’t see where. Thanks.
Pasting your code into the “Try Coffeescript” widget the code you expect, i.e. the alert inside the stop function:
Therefore I’m guessing tabs and spaces messing up indentation.