0

I am calling a fetch on a collection and inside its success methods fetching another collection. Once its done I am adding both the collections and rendering to the view. After I save a new item in the view, it saves in the db and after save is complete I am calling the methods that does fetching. All I want to do is to render the updated collection which now should include a newly crated model. But, When I debug step by step using chrome debugger, it gets the updated collection from the server otherwise the collection is not getting updated. I assume it is rendering before fetching. Page refresh is working just fine. Can you suggest anything I can do to change or delay rendering until fetch is complete?

4

1 回答 1

2

根据你给我的信息,你应该可以做这样的事情。

var promises = [];
_.each(models, function (model) {
    var destroying = model.destroy();
    promises.push(destroying);
});

$.when.apply(null, promises).done(this.displayAllRows);

您可能必须修改它,但这应该让您了解如何销毁所有模型然后渲染行。

于 2012-11-02T19:08:48.837 回答