Reputation: 2508
I have the following Coffeescript:
$ ->
$('#new_event').submit ->
$.post(
$(this).attr('action')
$(this).serialize()
(data, textStatus, jqXHR) ->
$('#target').html(data)
)
return false
And it translates to this:
$(function() {
return $('#new_event').submit(function() {
$.post($(this).attr('action'), $(this).serialize(), function(data, textStatus, jqXHR) {
return $('#target').html(data);
});
return false;
});
});
So far so good. However, how do I add another line into the submit? For example:
$ ->
$('#new_event').submit ->
test = $(this).serialize()
$.post(
$(this).attr('action')
$(this).serialize()
(data, textStatus, jqXHR) ->
$('#target').html(data)
)
return false
This gives unexpected INDENT error. Can't figure out what I'm missing here...
Thanks, Dany.
Upvotes: 4
Views: 3435
Reputation: 262474
Most likely you mixed spaces and tabs for indentation. Coffeescript does not like that.
And, by the way, you can write @
instead of this
.
Upvotes: 5