当前项未在新函数中定义(已延迟)
Currentitem undefined in new function ( Deffered)
我正在 SharePoint 中编辑项目显示模板。 出现以下问题:
ctx(clientcontext).currentitem 在自定义函数中变为未定义。我该如何解决这个问题。
下面是一个简短的代码片段:
var p = getFollowers();
console.log("")
console.debug(ctx.CurrentItem);
p.done(function(result) {
console.debug(followers);
console.debug(ctx);
});
我看不到我在这里错过了什么
编辑 1:
var results;
function successCallback() {
console.debug("test");
var clientContext = new SP.ClientContext.get_current();
var counts = 0;
var test = results.getEnumerator();
while (test.moveNext()) {
var person = test.get_current();
followers.push(person.get_displayName());
counts++;
}
$("#followers").text('(' + counts + ')');
this.d.resolve(followers);
}
function failCallback() {
this.d.reject("something bad happened");
}
function getFollowers()
{
var d = $.Deferred();
var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
// Get the people who are following the current user.
peopleFollowingMe = peopleManager.getMyFollowers();
clientContext.load(peopleFollowingMe);
results = peopleFollowingMe;
var o = {d: d, results:results};
clientContext.executeQueryAsync(Function.createDelegate(o, successCallback), Function.createDelegate(o, failCallback));
return d.promise();
}
我不是sharepoint的专家。我想知道 ctx 变量是否可以由 p.done() 修改。
为什么不在调用 p.done() 之前存储 CurrentItem?
var p = getFollowers();
console.log("");
var currentItem = ctx.CurrentItem;
console.debug(currentItem);
p.done(function(result) {
/* console.debug(followers); */
console.debug(currentItem);
});
顺便一提。您在回调中读取的关注者变量是什么?
相关文章:
- 如果JavaScript标签是通过谷歌标签管理器插入到页面上的,那么它们的延迟程度是多少;s的自定义HTML
- JavaScript 在自定义事件中延迟
- JS - 延迟脚本的执行,直到所有数据都已定义/可用
- 触发自定义 jQuery 事件并延迟它
- 异步函数返回未定义,$q延迟
- 当前项未在新函数中定义(已延迟)
- AngularJS 延迟加载在 1.3.x 迁移后中断,获取参数“XXCntr”不是一个函数,未定义
- 一种自定义动画 - 延迟不起作用
- 使用jQuery自定义JS Confirm Modals.延迟和基于按钮的返回值问题
- 我如何更改<p>使用javascript在定义的时间延迟后动态标记数据
- 延迟关键帧每定义的时间,并保持不透明度0动画后
- 延迟加载不工作与我的自定义分页
- 由于异步函数延迟执行和完成,变量返回预定义值
- 有没有很酷的方法来定义/计算PI使用延迟计算序列
- 自定义JQuery延迟处理程序
- JQuery:延迟加载JQuery和'$未定义'
- 自定义延迟加载- IE9内存泄漏
- jquery自定义延迟函数
- 自定义延迟加载函数将数据加载到容器中后,jQuery函数OnClick不起作用
- 如何触发自定义延迟事件