I have an underscore template and I have to use Mustache to render it. Below is my underscore template:
<div id="sub-account">
<p>something</p>
<table>
<tr><td>Name</td>
</tr>
<tbody>
<% _.each(accountList, function(account) { %>
<tr>
<td><%= account.get('name') %></td>
</tr>
<% }) %>
</tbody>
</table>
</div>
Im using a mustache as my main view to render a list. How can I loop through the code to render as a mustache template?
Backbone Collection:
var SubAccountCollection = Backbone.Collection.extend({
initialize: function(models, options) {
this.account = options.id;
},
url: function() {
return 'some/' +this.account + '/somelist';
}
});
return SubAccountCollection;
});
This is what im trying to do with the ajax call:
accountList.fetch({
success: function(accnlist){
setInterval(function(){
$('#sub-account-list').html(tmpl, {accnlist:accnlist.toJSON()})
}, 500);
},
error: function(err){
console.log('Error!', err)
}
});
should be something like that. didn't check though.