SPService SPGetListItemsJson からプロミス アイテムを取得しようとしています。問題は、SPGetListItemsJson が呼び出され、requestPromise が完了し、遅延が解決されたときに、データが populateDropDownControlWithList の匿名関数に渡されると予想されますが、未定義です。
function populateDropDownControlWithList(option, control, addSelectValue)
{
if (typeof (addSelectValue) === 'undefined')
{
addSelectValue = false;
}
var selectedIndex = control.val() ? control.val() : -1;
if (addSelectValue)
{
control.append('<option value=-1>Select an Option</option>');
}
var request = SPGetListItemsJson(option);
request.done(function (data) // Expect the json object here but it is undefined
{
$.each(data, function ()
{
controlappend('<option value=' + this.Id + '>' + this.Title + '</option>');
});
});
}
function SPGetListItemsJson(option)
{
var deferred = $.Deferred();
var requestsPromise = $().SPServices.SPGetListItemsJson({
listName: option.Name,
CAMLQuery: option.Query,
CAMLViewFields: option.View,
mappingOverrides: option.Mapping,
debug: option.Debug,
async: option.async
});
requestsPromise.done(function ()
{
deferred.resolveWith(this.data); // Verified this.data is populated with the correct result
});
return deferred.promise();
}
どんな助けでも大歓迎です!