Reputation: 143
for (var i = 1; i <= news.length; i++) {
var newsData = news.get(i);
var newsRow = JST["news/row"](newsData.attributes);
$("#news_tbody").prepend(newsRow).children('tr').addClass(function(){
if (newsData.get('is_read') == 1)
{return "news_read";}
else if (newsData.get('is_read') == 0)
{return "news_unread";}
});
In this case I want to load only rows where newsData.get('_type') == "friends"
.
I wonder how to specify it correctly.
Upvotes: 0
Views: 52
Reputation: 1799
_.each(news.where({ '_type': 'friends' }), function (item) {
var newsRow = JST['news/row'](item.toJSON());
$('#news_tbody').prepend(newsRow).children('tr').addClass(function () {
return item.get('is_read') ? 'news_read' : 'news_unread';
});
});
Upvotes: 1