Backbone.js and C#

December, 22nd 2011 | .NET

We are testing Backbone.js ì and I must say that the first approach was certainly exciting.
Some time now our applications are based on a structure heavily skewed on the client where the server is the only storage service and actually felt the need for an instrument of this type.

C#'s naming conventions include capital letters for the class members.
Backbone.js instead expects a lowered "id" attribute to handle objects in the model.
To force Backbone.js to use a custom attribute is sufficient to indicate, in the model extend method, the value of our key.

window.Company = Backbone.Model.extend({

    idAttribute: "Id"

});

This feature is not present in the official documentation but it is particularly useful and you can see it here.