0

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();
    }
4

1 に答える 1

0

私はシェアポイントの専門家ではありません。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);
 });

ところで。コールバックで読み取っているフォロワー変数は何ですか?

于 2016-01-24T18:51:45.727 に答える