骨干保存到服务器parse.com

时间:2013-07-30 14:20:40

标签: javascript backbone.js parse-platform

我正在使用骨干方法保存来更新parse.com上的用户对象。骨干中的对象基于模型和集合。当我拿到它时可以,但是当保存出现时:PUT https://api.parse.com/1/classes/_User/xj3QLLYy07 400(错误请求)

{ “代码”:206, “错误”: “解析:: UserCannotBeAlteredWithoutSessionError”}

型号:

var Person = Backbone.Model.extend({

    urlRoot: "https://api.parse.com/1/classes/_User/",

    idAttribute: "objectId",

    defaults:{
    },

    initialize: function() {
        console.log("inperson");
        // this.upload();
    }

});

return Person;

收集:

var Usercollection = Backbone.Collection.extend({

    model: Person,

    url:'https://api.parse.com/1/classes/_User/',

    parse: function(data) {
        return data.results;
    }

});

return Usercollection;

以及我尝试保存模型的代码:

this.model.save({email:"ciao@lib.it"}, {
    // wait:true,
    success:function(model, response) {
        console.log('Successfully saved!');
    },
    error: function(model, error) {
        console.log(model.toJSON());
        console.log(error.responseText);
    }
});

1 个答案:

答案 0 :(得分:0)

I think this answer needs an update. Cant you just swap the backbone collection and model to Parse's ones?

Here is a short example that worked for me today