Google News
logo
Backbone - Interview Questions
What is Backbone.sync is used for?
Backbone.sync is a function that is Backbone js call every time it attempts to read or save a model to the server.By default, it uses jQuery.ajax to make a RESTful JSON request and returns a jqXHR
 
Example Code :
Backbone.sync = function(method, model) {
  alert(method + ": " + JSON.stringify(model));
  model.set('id', 1);
};

var author= new Backbone.Model({
  author: "Sharad",
  website: "https://www.freetimelearning.com"
});

author.save();

author.save({author: "FTL"});

 

Advertisement