Javascript jQuery Mobile未呈现下划线JS模板
我试图在我的jQuery移动应用程序中呈现一个下划线JS模板,但是,它似乎无法呈现。这是一个例子Javascript jQuery Mobile未呈现下划线JS模板,javascript,jquery,jquery-mobile,underscore.js,Javascript,Jquery,Jquery Mobile,Underscore.js,我试图在我的jQuery移动应用程序中呈现一个下划线JS模板,但是,它似乎无法呈现。这是一个例子 下划线未定义。如果正确引用下划线库,它将正常工作:谢谢您的回答! <script type="text/template" id="workers-template"> <table class="table"> <thead> <tr> <th>Worker</th>&l
下划线未定义。如果正确引用下划线库,它将正常工作:谢谢您的回答!
<script type="text/template" id="workers-template">
<table class="table">
<thead>
<tr>
<th>Worker</th><th>Description</th><th>Store</th><th></th>
</tr>
</thead>
<tbody>
<% _.each(workers, function(worker) { %>
<tr>
<td><%= worker.user %></td>
<td><%= worker.description %></td>
<td><%= worker.store %></td>
<td></td>
</tr>
<% }); %>
</tbody>
</table>
</script>
<div id="container"></div>
var workers = [{user:"alicia", description:"fast", store:"Target"},
{user:"allen", description:"moderate", store:"n/a"},
{user:"bart", description:"fast", store:"Krispy Cremes"}];
var workersTemplate = _.template($('#workers-template').html(), {workers:workers});
$(workersTemplate).appendTo("#container").enhanceWithin();