What is Backbone.sync is used for?

devquora
devquora

Posted On: Feb 22, 2018

 

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.onlineinterviewquestions.com"
});

author.save();

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

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Backbone js Interview Questions

    Explain what is Backbonejs?

    Backbone.js is a client-side (Model, View, Controller) MVC-based JavaScript framework.It purely is written in Javascrip..

    Backbone js Interview Questions

    List Dependencies of using BackboneJs?

    Backbone’s Js only hard dependency is Underscore.js ( >= 1.8.3). For RESTful persistence and DOM manipulation with..

    Backbone js Interview Questions

    What is the use of BackboneJS route?

    The Backbone.js router is used to change the URL fragment or hashes of an application to create bookmarkable and shareab..