我将 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");
}
});
},
但它没有工作......
任何建议将不胜感激,谢谢:)