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

Silly I am ~

It should be:

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 回答