obj {column1{name:abc, items{price:10, count:5}, title:def}}
I have an object as above, the count has been added after an loop ajax succession to the object obj, I will then append the obj to the underscore template.
I did a console.log of the obj after adding count into the obj and it appears to be there. When I do a loop of items in the template, count seems to be missing. I did another console.log of items in the template and count is appears to be there.
Anyone knows the mystery of count?
$.each(rows, function(i, row) {
$.each(row.items, function(i, item) {
$.ajax({
url: 'route',
data: { data: datapost },
type: 'GET',
success: function(num){
item.count = num;
}
});
});
});
$('#container').append(template(row));
the missing count in the template:
<% _.each(items, function(item) { %>
<%= item.price %> <%= item.count %>
<%})%>