For a id on a model in backbone, its just id
and all lower cased. What if my Id on the server is called UserId
. In the parse method for backbone, how do I change UserId
to id
and use the same names for all other properties?
For eg.
window.User = Backbone.Model.extend({
defaults:
{
UserId: 0, // <--can i just tell backbone that this is my id?
Name: '',
Age: 0
}
parse: function(response){
var model = response;
model.id = response.UserId;
return model;
}
});
Is there a better way to do this?
How about telling backbone model that my id is of type UserId
.