Reputation: 13
i'm getting the above error when i try to load one of my underscore templates. I'm guessing its some sort of issue in the for loop (which should probably be an -.each but i don't quite get the structure of those yet).
my template
<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>
and its been called by the following
$('#tableDiv').html(_.template($("#Customer-List-View").html(), {'customers': globalCustomerList}));
I'm sure it something really simple but its my first table in a template and i just can't see the problem.
Any help greatly receieved
Upvotes: 1
Views: 2254
Reputation: 222128
You're using commas instead of semicolons in the for
.
<% for (var i = 0, i < customers.length, i++){ %>
should be
<% for (var i = 0; i < customers.length; i++){ %>
Upvotes: 3