CoffeeScript – 无与伦比的外观
我一直在尝试将我的工作javascript代码传递给CoffeeScript,但我无法传递此错误:
55号线无与伦比的OUTDENT
这是coffeescript代码
$(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; );
我试过放和擦除;
到处都是,但我没有错。 我也尝试更改->
for =>
但弹出相同的错误。
有效的JS并不是真正有效的CoffeeScript。 你必须做这样的事情:
$(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
另外,对此行做一些事情:
$form = $(this).parent().parent().parent().parent().parent().parent()
.closest()
应该会有所帮助。
- 错误:未知提供者:aProvider < – a
- 如何配置Rails 3.2 + / 4以生成.js而不是.js.coffee默认情况下?
- Rails,CoffeeScript和ERB
- Marionette CompositeView为Collection中的每个Model而不是ItemView(Marionette Rails)渲染自己
- 如何将CoffeeScript(或JavaScript)执行限制在Rails 3.1中的特定控制器和操作?
- Coffeescript / Javascript在服务器上不起作用
- 使用CoffeeScript以编程方式检查复选框
- Rails 4 + ReactJS:“SyntaxError:隐式对象中不能有隐式值”
- 条带集成 – 将attr值动态添加到hidden_field中