我将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");
}
});
},
但它没有用......
任何建议都会表示赞赏,谢谢:)
答案 0 :(得分:0)
我很傻〜
应该是:
saveScore:function () {
this.updateScore();
this.save(null, {
success: function(scoreData) {
alert("saveSuccess" + scoreData.id);
},
error: function(error) {
alert("saveError");
}
});
},