我在这里有一个益智游戏。我有以下的集合:将一个JSON对象分成几个集合对象
var TagsCollection = Backbone.Collection.extend({
model: TagModel,
parse : function(response) {
console.log(response);
// code to go
return response;
}
});
现在取下面的示例JSON对象:
{
id: 10149682,
published: "2014-01-13 08:23:00",
title: "Title",
tags: "tag1,tag2,tag3,tag4"
}
现在我要的是插入一些代码,将重新映射现有的响应为以下格式:
[{name: "tag1"}, {name: "tag2"}, {name: "tag3"}, {name: "tag4"}]
并将其加载到集合中。 (一个重要的注意事项 - 使用Backbone/Underscore方法 - 用于例如.chain/_.reduce等)。