下面,我利用骨干 j收集。 在请求的答复中,我谨对收集数据进行定量表示某种逻辑。 我正在修改关于育儿(来源类型)的教区法,以附上儿童收集资料(来源账户),如果实际上有来源账户,则只包括来源类型。
我不想这样做,而没有把全部数据主要装上,因此,我用javascript说出,唯一安全的道路是成功的警示。
如你在以下法典中可以看到,在教区职能范围内,我建造了一个称为“反应-目标”的新物体。 问题是,如果试图在成功呼吁中包装这一物体,则收集工作并不包括任何一包装的物体。 你们将如何改写这段话,使这项工作正确无误?
window.AdminSourceTypes = Backbone.Collection.extend({
model: window.AdminSourceType,
url: /api/sources ,
parse: function(response){
// create response object
response_object = [];
x = 0;
_.each(response, function(item){
//get child collection (accounts) from one of "source type s" attributes
collection = new window.AdminAccounts();
collection.url = item.accounts_url;
//get all accounts
collection.fetch({
//only add the source type to the response object
//if there are accounts associated to it
success: function(accounts_collection){
if(accounts_collection.size() > 0){
response_object[x] = item;
}
}
});
x++;
});
return response_object;
}
});