我想使用parse.com连接模型和集合,但我很困惑。我打算通过骨干和JavaScript API parse.com集合来获取,但比较这个错误:POST https://api.parse.com/1/classes 404(Not Found)。骨干和parse.com模型和集合之间的连接
型号:
var Person = Backbone.Model.extend({
defaults:{
},
initialize:function(){
console.log("inperson");
this.validate();
this.send();
},
validate:function(){
console.log("validate");
},
send:function(){
var user = new Parse.User();
user.set("username", this.get("username"));
user.set("password", this.get("password"));
user.set("email", this.get("email"));
user.signUp(null, {
success: function(user) {
// Hooray! Let them use the app now.
},
error: function(user, error) {
// Show the error message somewhere and let the user try again.
alert("Error: " + error.code + " " + error.message);
}
});
}
});
return Person;
});
收藏:
var Usercollection = Parse.Collection.extend({
model:Person,
initialize:function(){
}
});
return Usercollection;
});
最后调用的总汇和获取的观点:
var HomeView = Backbone.View.extend({
template: Handlebars.compile(template),
events: {
},
initialize: function() {
console.log("inhomeview");
var amici = new Usercollection();
amici.fetch({
success: function(collection) {
amici.each(function(object) {
console.warn(object);
});
},
error: function(amici, error) {
// The collection could not be retrieved.
}
});
},
render: function() {
}
});
return HomeView;
});
有人可以向我解释一个示例来创建一个模型,并通过parse.com进行收集和获取? – 2013-05-03 12:59:22
您必须遵循REST API文档https://parse.com/docs/rest – 2013-05-03 14:29:01
我可以通过javascript api而不使用其他API吗? – 2013-05-03 15:25:44