我想使用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