jQuery Mobile不呈现UnderscoreJs模板

时间:2014-06-30 14:00:01

标签: javascript jquery jquery-mobile underscore.js

我试图在我的jQuery移动应用中渲染UnderscoreJs模板,但是,它似乎无法呈现。这是jsFiddle

<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();

0 个答案:

没有答案