CoffeeScript - Unmatched OUTDENT

coffeescript, javascript, ruby-on-rails

Solution

Valid JS isn't really valid CoffeeScript. You'd have to do something like this:

$(document).on "click", ".save_button", ->
    $form = $(this).parent().parent().parent().parent().parent().parent()

    $form.bind "ajax:complete", ->
        $actionURI = $form.attr "action"
        $.ajax
            type: "get"
            url: "#{window.location.protocol}//#{window.location.host}#{$actionURI}.js"
            dataType: "html"
            success: ->
                $form.parent().parent().prev().html(data)
                closeSaveElement()

    $form.submit()

    return false

Also, do something about this line:

$form = $(this).parent().parent().parent().parent().parent().parent()

`.closest()` should be helpful.

Problem

I've been trying to pass my working javascript code into CoffeeScript but i can't get pass this error: unmatched OUTDENT on line 55 This is the coffeescript code ``` $(document).on("click",".save_button", -> $form = $(this).parent().parent().parent().parent().parent().parent() $form.bind("ajax:complete", -> $actionURI = $form.attr("action"); $.get(window.location.protocol+"//"+window.location.host+$actionURI+".js",(data) -> $form.parent().parent().prev().html(data); //Line 55 closeSaveElement() ,"html") ); $form.submit(); return false; ); ``` i've tried putting and erasing `;` everywhere but i don't whats wrong. I also tried to change `->` for `=>` but the same error pops up.

Original source