Skip to content

Instantly share code, notes, and snippets.

@shohey1226
Created June 15, 2013 05:45
Show Gist options
  • Save shohey1226/5787068 to your computer and use it in GitHub Desktop.
Save shohey1226/5787068 to your computer and use it in GitHub Desktop.
app.models.Employee = Backbone.Model.extend({
initialize:function () {
this.reports = new app.models.ReportsCollection();
this.reports.parent = this;
},
sync: function(method, model, options) {
if (method === "read") {
app.adapters.employee.findById(parseInt(this.id)).done(function (data) {
options.success(data);
});
}
}
});
app.models.EmployeeCollection = Backbone.Collection.extend({
model: app.models.Employee,
sync: function(method, model, options) {
if (method === "read") {
app.adapters.employee.findByName(options.data.name).done(function (data) {
options.success(data);
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment