javascript - Uncaught SyntaxError: Unexpected token ')' in underscore when looping throught template -
i have problem when using underscore in backbone application. in console have
uncaught syntaxerror: unexpected token ')'
and referer me underscore library :
underscore.js:line 1443
what whant select template id
var userlist = backbone.view.extend({ el: '.page', render: function(){ var self = this; var users = new users(); users.fetch({ success:function(users){ console.log(users); var template = _.template($('#user_list_template').html(), users); self.$el.html(template); } }); } });
here script template
<script type="text/template" id="user_list_template"> <table class="table striped"> <thead> <tr> <th>name</th> <th>age</th> </tr> </thead> <tbody> <% _.each(users,function(user)){ %> <tr> <td><%= user.name %></td> <td><%= user.age %></td> </tr> <% }); %> </tbody> </table> </script>
and found, problem in line:
var template = _.template($('#user_list_template').html(), users);
could me please find problem?
<% _.each(users,function(user)){ %>
line has )
before {
in template.
Comments
Post a Comment