Skip to content
Pierre Besson edited this page Aug 12, 2014 · 2 revisions

Model.js

A model has to inherit from a Backbone.Model. It looks like this:

var ContactModel = Fmk.Models.Model.extend({
  modelName: "contact"
  url: "http://domain/api/contact",
  initialize: function(options){
    //Some initialization code here.
    if(!this.isNew()){
      this.set({creationDate: new Date()});
    }
  },
  metadatas:{
    firstName: {
      "doamain": "DO_SHORT_LABEL"
    }
  }
});
  • Has an url property
  • Has metadatas
  • Maintain attributes (modelName and metadatas attributes)
  • Trigger events when updtated
  • In the Fmk.js the default Backbone model has been extended mainly in order to deal with medatdatas.
  • It also have special methods in order to be save.
  • The json model is the input and the output of the services.
Clone this wiki locally