Ok I have a fix for the problem, even though it is not quite a satisfying one, because I can't really explain why this now works and my old code doesn't. So if anyone has an idea, I'd still appreciate some explanation what I did wrong. Anyways now my working code looks like this
- getFilteredListMultiple: function(ListName, AndOrFilter){
- var deferred = new $.Deferred();
-
- var result = [];
- var andFilteredLists = [];
- var returned =[];
-
- $(AndOrFilter).each(function(index){
- andFilteredLists[index] = aceSpListLookup.list.getFilteredList(ListName, this);
- })
-
- $.when.apply($, andFilteredLists).done(function(){
- result = andFilteredLists[0].Result.responseJSON.d.results;
- for(i=1; i<andFilteredLists.length; i++){
- $(andFilteredLists[i].Result.responseJSON.d.results).each(function(){
- result.push(this);
- });
- }
- }).done(function(){
- $(result).each(function(index){
- returned[index] = this;
- });
- deferred.resolve();
- });
- return deferred.promise({Result: returned});
- }
- }
So basically I added another array, that gets filled with the exact same values and return that one. Unfortunately I can't really explain why that worked and the previous code wouldn't. Maybe you guys have an idea. Thanks again and
Greetings Chris