jQuery(function($) {
// create a convenient toggleLoading function
var toggleLoading = function() { $("#loading").toggle() };
$("#new_post")
.bind("ajax:loading", toggleLoading)
.bind("ajax:complete", toggleLoading)
.bind("ajax:success", function(event, data, status, xhr) {
$("#response").html(data);
});
});
this is my js function (or Simone Carletti's) and I want to transform it to coffeescript, I am having trouble with the last two callbacks, though.
My coffeescript looks like this
jQuery ->
$("#new_post")
.bind("ajax:loading", toggleLoading)
.bind("ajax:complete", toggleLoading)
.bind("ajax:success", (event, data, status, xhr) ->
alert(data)
.bind("ajax:failure", (event, data, status, xhr) ->
alert(data)
but I am getting an Error: unclosed INDENT on line 21
thanks in advance