coffeescript缩进

时间:2013-01-21 16:01:20

标签: javascript asp.net coffeescript

我收到这些行的缩进错误

有没有可以帮助我的在线验证工具?

showAliveTests : (pageIndex, statusFilter) ->
    data=
            pageIndex:pageIndex
            status:statusFilter
        $.ajax 
            url:'/ManageConfiguration/GetAliveConfigurations/' + location.search
            type:"post"
            data:data
            dataType:"json"
            success:(res)->
                if res.status == "failed"
                    alert res.body
                else
                    $('#viewConfigurationTable tr').remove()
                    newRow =    $ '<tr>'
                    newRow.append('<td>Id</td>
                                    <td>Name</td>
                                    <td>Status</td>
                                    <td>Ctids</td>
                                    <td>CreationDate</td>')
                    $('#viewConfigurationTable').append(newRow)
                    for obj in res.body
                        newRow =    $ '<tr>'
                        newRow.append('<td>'+obj.Id+'</td> 
                                        <td>'+obj.Name+'</td>
                                        <td>'+obj.Status+'</td>
                                        <td>'+obj.Ctids+'</td>
                                        <td>'+obj.CreationDate+'</td>')
                    $('#viewConfigurationTable').append(newRow) 
                    $(#paginator a).remove()
                    for i in [0..count] by 1
                        $(#paginator).append('<a href=#>'+i+'</a>') 

            error:(e)->
                alert 'An error has occured: ' + e

2 个答案:

答案 0 :(得分:4)

www.coffeescript.org - &gt;点击试试我,将你的代码粘贴到内部,你会看到哪一行引发错误。

在您的情况下,即使使用stackoverflow代码突出显示,您也可以看到它:

$(#paginator a).remove() -> wrong
$('#paginator a').remove() -> correct

第二次错误

$(#paginator).append('<a href=#>'+i+'</a>')  -> wrong
$('#paginator').append('<a href=#>'+i+'</a>')  -> correct

答案 1 :(得分:1)

您忘记了#paginator apaginator

周围的引号
#...
$("#paginator a").remove() # you had: $(#paginator a)
for i in [0..count] by 1
    $("#paginator").append('<a href=#>'+i+'</a>') # you had: $(#paginator)
#...