我已经通过 parse.com 上的 apirest 在骨干网中获取了一个集合,但在 console.log 中我可以读取这个结果:child {collection: child, attributes: Object, _escapedAttributes: Object, cid: "c2", changed: Object …}。
那么结果在哪里??在我的收藏中,有用户名,用户名 ecc..
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);
console.log(object);
});
},
error: function(amici, error) {
// The collection could not be retrieved.
}
});
收藏:
var Usercollection = Backbone.Collection.extend({
model:Person,
url:'https://api.parse.com/1/classes/User',
模型:
var Person = Backbone.Model.extend({
defaults:{
},
initialize:function(){
console.log("inperson");
},
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"));
// other fields can be set just like with Parse.Object
//user.set("phone", "415-392-0202");
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;
});