CoffeeScript - 无与伦比的 OUTDENT
我一直在尝试将我的工作 javascript 代码传递给 CoffeeScript,但我无法通过此错误:
I've been trying to pass my working javascript code into CoffeeScript but i can't get pass this error:
第 55 行不匹配的 OUTDENT
unmatched OUTDENT on line 55
这是咖啡脚本代码
$(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.
推荐答案
有效的 JS 并不是真正有效的 CoffeeScript.你必须这样做:
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()
应该会有所帮助.
相关文章