【问题标题】:What's wrong with this simple coffeescript?这个简单的咖啡脚本有什么问题?
【发布时间】:2012-03-09 06:42:56
【问题描述】:
$('#<%= dom_id(@response[:domain]) > div.queries > #<%= dom_id(@response[:tag]) %>').fadeOut ->
  $(this).remove()

它在日志中产生以下错误:

ActionView::Template::Error (compile error
app/views/domains/untag.js.coffee:2: syntax error, unexpected $undefined
  $(this).remove()
   ^
app/views/domains/untag.js.coffee:3: unterminated string meets end of file
app/views/domains/untag.js.coffee:3: syntax error, unexpected $end, expecting kEND):
    1: $('#<%= dom_id(@response[:domain]) > div.queries > #<%= dom_id(@response[:tag]) %>').fadeOut ->
    2:  $(this).remove()
  app/views/domains/untag.js.coffee:3:in `compile'
  app/controllers/domains_controller.rb:45:in `untag'

【问题讨论】:

    标签: ruby-on-rails-3 coffeescript


    【解决方案1】:

    问题(至少是其中一个)出在您的字符串中

    '#<%= dom_id(@response[:domain]) > div.queries > #<%= dom_id(@response[:tag]) %>'
    

    您打开了两个&lt;%= 块,但只关闭了一个。

    【讨论】:

    • 谢谢 sergio,看来我所有的问题都与这样的语法错误有关
    【解决方案2】:

    奇怪,它为我编译。你用什么设置编译?

    CoffeeScript Test Reference Link

    【讨论】:

      猜你喜欢
      • 2012-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-11
      • 1970-01-01
      • 1970-01-01
      • 2012-05-09
      • 1970-01-01
      相关资源
      最近更新 更多