Reputation: 205
I have been reading up on Backbone.sync and the Backbone parse. I admit I am confused. I have a BB model that is inheriting from another model and its sending all the attributes to the page. I want to limit the attributes it sends to the page, right now it is sending everything from the database table (only want id, fname, lname, etc). This model wont be used to save, its only for reference within the page. My question is do I override the Backbone.sync or the parse and do I do it on the inheriting model or the "super" model?
Initial call:
TSS.Principal = new TSS.Models.User(@Html.Raw(this.User.ToJson()));
Inheriting Model that principal will use:
TSS.Models.User = _.extend(TSS.Models.User, {
parse: function (response, options) {
this.set("roles", new TSS.Collections.Roles(response.Roles));
response.Roles = null;
return TSS.Models.User.parse.call(this, response, options);
}
});
Actual "super" Model:
TSS.Models.User = Backbone.Model.extend({
idAttribute: "Id",
urlRoot: TSS.Paths.Data + '/UsersApi'
});
Upvotes: 2
Views: 160
Reputation: 29083
You should be doing this serverside (in your User.ToJson()
function) and prevent the data from ever being sent down to the clientside JavaScript code.
Upvotes: 1