praks5432
praks5432

Reputation: 7792

Coffee script compilation error

This is my coffee, I simply can't see why this is wrong. I keep getting an unexpected , error.

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)
    )

When I take out the @tbody.selectAll("tr"), this works, which is what's confusing me.

How do I fix this?

Upvotes: 0

Views: 69

Answers (1)

Justin Chmura
Justin Chmura

Reputation: 2027

I believe it has to do with the way you are defining your window.setTimeout section. The ,500) piece at the end is causing the compile error because of indentation and the parenthesis. Try changing that section to:

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

Keep the closing paren indented to the same spot as window. That should fix the compile.

Upvotes: 3

Related Questions