can anyone see any mistakes in this code? I use this approach throught my application, almost identically, but for some reason I simply cannot seem to resolve the main promise "a";
Parser.prototype.insertSomeData = function(data)
{
var a = $.Deferred(),
table = "Example",
columns = ["col1", "col2", "col3"];
var deferreds = [];
// insert Data into the database
for (var i = 0; i < data.length; i++)
{
var dfd = $.Deferred();
deferreds.push(dfd.promise());
item = data[i];
database.insert(table, columns, [item.one, item.two, item.three], function(){console.log("resolved"); dfd.resolve()}, dfd.reject);
}
$.when.apply(null, deferreds).then(function(){console.log("it worked!"); a.resolve()});
return a.promise();
}
both the promises in the deferred array do get resolved. So I think the problem is in the when Any see something I'm missing?