Monday, June 3, 2024
182
rated 0 times [  183] [ 1]  / answers: 1 / hits: 34008  / 14 Years ago, fri, november 12, 2010, 12:00:00

I've been looking at CoffeeScript and I'm not understanding how you would write code like this. How does it handle nested anonymous functions in its syntax?



;(function($) {
var app = $.sammy(function() {

this.get('#/', function() {
$('#main').text('');
});

this.get('#/test', function() {
$('#main').text('Hello World');
});

});

$(function() {
app.run()
});
})(jQuery);

More From » coffeescript

 Answers
31

didn't actually compile it, but this should work



(($) ->
app = $.sammy ->

this.get '#/', ->
$('#main').text ''

this.get '#/test', ->
$('#main').text 'Hello World'

$(->
app.run()
)
)(jQuery);

[#94987] Wednesday, November 10, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
billt

Total Points: 608
Total Questions: 100
Total Answers: 87

Location: Cape Verde
Member since Fri, Nov 27, 2020
4 Years ago
billt questions
Fri, Sep 10, 21, 00:00, 3 Years ago
Tue, Aug 18, 20, 00:00, 4 Years ago
Sat, Apr 6, 19, 00:00, 5 Years ago
;