3

下面的条件 (if) 语句返回此浏览器错误:“Uncaught TypeError: Object 46 has no method 'replace'” in the jsrender.js file on line 463(在 Chrome 和 IE8 中)

**2012-06-10 更新---对不起,在我原来的帖子中,我过于简化了我的场景,并且错误不存在。我已经更新了代码(如下)以更准确地表示我看到的错误。如果您从该代码中删除 {{if 1==1}} 行,它将完美运行。这条线完好无损,我得到了上述错误。

<script id="tmpl_report_entry_table_data_rows" type="text/x-jsrender">
    {{if 1==1}}
    <tr class="attribute_data_row">
        <td class="entry_id attribute_data"><span>{{:ENTRY_ID}}</span></td>
        <td class="attribute_1 attribute_data hidden"><span>{{:ATTRIBUTE__1}}</span></td>
        <td class="attribute_2 attribute_data"><span>{{:ATTRIBUTE__2}}</span></td>
        <td class="attribute_14 attribute_data"><span>{{:ATTRIBUTE__14}}</span></td>
        <td class="attribute_13 attribute_data"><span>{{:ATTRIBUTE__13}}</span></td>
        <td class="attribute_11 attribute_date attribute_data"><span>{{:ATTRIBUTE__11}}</span></td>
        <td class="attribute_11 attribute_date_hidden"><span>{{:ATTRIBUTE__11}}</span></td>
        <td class="attribute_3 attribute_data"><span>{{:ATTRIBUTE__3}}</span></td>
        <td class="attribute_4 attribute_data"><span>{{:ATTRIBUTE__4}}</span></td>
        <td class="attribute_5 attribute_data">
            <a href="?"><span>{{:ATTRIBUTE__5}}</span></a>
        </td>
        <td class="cmd"></td>
    </tr>    
    {{/if }}
</script>

<script>
    var obj_my_data = [
        {"ENTRY_ID":79,
            "test":true,
            "ATTRIBUTE__1":"Aleutian Islands",
            "ATTRIBUTE__2":"Arrowtooth Flounder",
            "ATTRIBUTE__13":"BSAI trawl limited access",
            "ATTRIBUTE__3":"Open",
        "ATTRIBUTE__4":"TAC",
        "ATTRIBUTE__5":"",
        "ATTRIBUTE__11":",",
        "ATTRIBUTE__14":"Entire GOA"},
        {"ENTRY_ID":80,
        "test":true,
        "ATTRIBUTE__1":"Aleutian Islands",
        "ATTRIBUTE__2":"Atka Macherel",
        "ATTRIBUTE__13":"BSAI trawl limited access",
        "ATTRIBUTE__3":"Open",
        "ATTRIBUTE__4":"TAC",
        "ATTRIBUTE__5":"",
        "ATTRIBUTE__11":",",
        "ATTRIBUTE__14":"Entire GOA"}
    ];

    $(document).ready(function(){  
        $("table tbody").append($("#my_template").render(obj_my_data)); 
    });
</script>
4

1 回答 1

2

抱歉没有看到你的更新。结束 if 标记有额外的空白。应该是{{/if}},不是{{/if }}

于 2012-06-18T04:58:50.523 回答