1

以下のように Parse.Object をサブクラス化しました。

    var CFSScoreData = Parse.Object.extend("CFSScoreData",
{
    initialize:function () {
        this.playerName = "RACCOON";
        this.playTimeInSec = 0;
        this.rank = 0;
            this.updateScore();
    },
    updateScore:function () {
        this.set("playerName", this.playerName);
        this.set("playTimeInSec", this.playTimeInSec);
        this.set("rank", this.rank);
    },
    saveScore:function () {
        this.updateScore();
        this.save(null, {
              success: function() {
                  alert("saveSuccess");
              },
              error: function(error) {
                  alert("saveError");
              }
        });
    },
}
);

これはうまくいきました。

しかし、保存後にオブジェクトのIDを取得したいので、試しました:

saveScore:function () {
    this.updateScore();
    this.save(null, {
          success: function(this) {
              alert("saveSuccess" + this.id);
          },
          error: function(error) {
              alert("saveError");
          }
    });
},

しかし、うまくいきませんでした...

アドバイスをいただければ幸いです、ありがとう:)

4

1 に答える 1

0

愚かな私は〜

そのはず:

saveScore:function () {
    this.updateScore();
    this.save(null, {
          success: function(scoreData) {
              alert("saveSuccess" + scoreData.id);
          },
          error: function(error) {
              alert("saveError");
          }
    });
},
于 2013-03-13T08:27:58.173 に答える