1

当我尝试加载我的一个下划线模板时出现上述错误。我猜测它在 for 循环中存在某种问题(可能应该是 -.each 但我还不太了解它们的结构)。

我的模板

    <script type="text/html" id="Customer-List-View">
    <p> Please click on a customer to select </p>
        <table >
            <thead>
                <th> Customer Name </th><th>Last Invoice date</th><th>Last item added</th>
            </thead>

            <tbody>
                <% for (var i = 0, i < customers.length, i++){ %>
                    <tr class="cusTableRow"  id="<%=customers[i].objectId %>" >
                        <td> <%= customers[i].custName %> </td>
                        <td> <%= customers[i].custLastInvoiceDate %> </td>
                        <td> <%= customers[i].CustLastItemDate %> </td>
                    </tr>

                <% }; %>
            </tbody>
        </table>
        <button id="customerAdd"> Add a new customer </button>

    <p> here should be a set of buttons for working with customers </p>

</script>

它被以下调用

$('#tableDiv').html(_.template($("#Customer-List-View").html(), {'customers': globalCustomerList}));

我确信它非常简单,但它是我在模板中的第一个表,我只是看不到问题所在。

任何帮助都得到了极大的帮助

4

1 回答 1

3

您在for.

<% for (var i = 0, i < customers.length, i++){ %>

应该

<% for (var i = 0; i < customers.length; i++){ %>
于 2013-08-28T14:32:42.660 回答