Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta name=”description” content=”Backbone.js tutorial code sample”>  
<link rel=”author” href=”https://plus.google.com/u/0/+ArvindRavulavaru“/>
<title>Backbone.js Tutorial - Arvind Ravulavaru</title>
  
</head>
<body>
  
  
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  <script type="text/javascript" src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
  <script type="text/javascript" src="http://documentcloud.github.com/backbone/backbone-min.js"></script>  
</body>
</html>
 
Backbone.sync = function(method, model, options) {
  function success(result) {
    // Handle successful results from MyAPI
    if (options.success) {
      options.success(result);
    }
  }
  function error(result) {
    // Handle error results from MyAPI
    if (options.error) {
      options.error(result);
    }
  }
  options || (options = {});
  switch (method) {
    case 'create':
      return MyAPI.create(model, success, error);
    case 'update':
      return MyAPI.update(model, success, error);
    case 'patch':
      return MyAPI.patch(model, success, error);
    case 'delete':
      return MyAPI.destroy(model, success, error);
    case 'read':
      if (model.attributes[model.idAttribute]) {
        return MyAPI.find(model, success, error);
      } else {
        return MyAPI.findAll(model, success, error);
      }
  }
};
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
arvindr21pro
0viewers