Yet another question about promises. I have this scenario:
Service.prototype.parse = function (data) {
    var deferred = $.Deferred();
    var arr      = [];
    for (var i = 0; i < data.length; i++) {
        var details = new Details();
        $.when(details).then(function (data) {
            arr.push(data);
            deferred.resolve(arr);
        });
    }
    return deferred.promise;
};
Somewhere else in the code:
...
$.when(parse()).then(function (resp) {
   //...
});
The promises get resolved at some point but initially resp has a length of 1.
How to wait for parse() to resolve everything and return a array?
 
     
     
    