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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -