when/done 中的回调从未被调用

callback in when/done never getting called

在我的两个集合中都没有条目的情况下,渲染函数从未被调用。问题:解决 jQuery when/done 需要返回的最低限度是多少?

$.when(collection2.fetch(), collection2.fetch())
    .done(function(data, data2){
        ...
        _this.render();
    });

注意,我用 Backbone.js 标记了这个问题,以表明获取请求是 Backbone.Collection.fetch()。

没有 fetch 的代码,我只能建议最小值。

如果您的 collection 是空的,return $.Deferred().resolve().promise() 来自 fetch() 并且 运行 done 立即(立即 两者当然会得到解决)