Parsing 具有save函数的Parse.Object的子类
我将Parse.Object子类化,如下所示:Parsing 具有save函数的Parse.Object的子类,parsing,Parsing,我将Parse.Object子类化,如下所示: var CFSScoreData = Parse.Object.extend("CFSScoreData", { initialize:function () { this.playerName = "RACCOON"; this.playTimeInSec = 0; this.rank = 0; this.updateScore(); }, u
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");
}
});
},
但它不起作用
任何建议都将不胜感激,谢谢:)我真傻~
应该是:
saveScore:function () {
this.updateScore();
this.save(null, {
success: function(scoreData) {
alert("saveSuccess" + scoreData.id);
},
error: function(error) {
alert("saveError");
}
});
},