我无法获得 $.when.apply 来评估数组中定义的任何函数,我在这里做错了什么?
function Logic(address) {
this.address = address;
}
Logic.prototype.Get = function (pk, success, failure) {
var scope = this;
return $.ajax({
url: scope.address + '/Get',
type: "GET",
data: { 'pk': pk },
contentType: "application/json; charset=utf-8",
success: function (data) {
success(data.hasOwnProperty("d") ? data.d : data);
},
failure: function (ex) {
failure(ex);
}
});
};
function Screen(options) {
var scope = this;
if (options.pullings != null)
{
$.each(options.pullings , function (i, pulling)
{
scope.pullings.push(function () {
return pulling.logic.Get($('[name="' + pulling.pkField + '"]').val(),
function (row) {
$('#' + pulling.displayControlID).val(row[pulling.displayField]);
}, null);
});
});
}
}
Screen.prototype.Fill = function (pk) {
var scope = this;
$.when.apply($, scope.pullings).then(function () {
// none of the functions ever gets called and just enters this block
});
}