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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With