Note: Only Properties will get transferred to the server. Observables and other values will not.
var Profile = App.Model({
options: {
idAttr: 'id',
create: {
url: 'profile/create'
}
}
});
var profile = Profile({
username: 'user1'
});
profile.sync();
var Profile = App.Model({
options: {
idAttr: 'id',
update: {
url: 'person/update'
}
},
changePassword: function (newPassword) {
this.password(newPassword);
this.sync();
}
});
var Person = App.Model({
options: {
idAttr: 'id',
destroy: {
url: 'person/destroy'
}
},
deleteItem: function () {
this.destroy();
this.sync();
}
});
You could find how to populate collection of objects from a service here