2013-07-02 172 views
0

这是我的咖啡,我根本看不出为什么这是错误的。我不断收到意想不到的错误。咖啡脚本编译错误

renderTable:()=> 
    @table = d3.select("#search-results-area").append("table").attr("id",@tableId).attr("class","visualization-panel") 
    @thead = @table.append("thead") 
    @tbody = @table.append("tbody") 
    @input = @table.append("input").attr("id",@inputId).on("keydown",(d)=> 
     console.log("keydown") 
     console.log 
     toFilter = $(@input[0][0]).val() 
     window.setTimeout(()=> 
      toFilter = $(@input[0][0]).val() 
      @tbody.selectAll("tr") 
     ,500) 
    ) 

当我拿出@tbody.selectAll("tr"),这工作,这是什么让我感到困惑。

我该如何解决这个问题?

回答

3

我相信它与您定义window.setTimeout部分的方式有关。 ,500)段最后由于缩进和括号而导致编译错误。试着改变该条:

window.setTimeout (-> 
    toFilter = $(@input[0][0]).val() 
    @tbody.selectAll("tr") 
), 500 

保持缩进到同一地点window闭幕括号。这应该修复编译。