[Pkg-javascript-commits] [backbone] 118/211: Issue #289. Enable the use of jQuery.Deferred by returning Deferred objects from save() and fetch() calls.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:00:11 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.5.0
in repository backbone.

commit 222d673dccd7f82e1d2ca65cf451c893e943a74d
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Mon Apr 18 17:08:34 2011 -0400

    Issue #289. Enable the use of jQuery.Deferred by returning Deferred objects from save() and fetch() calls.
---
 backbone.js  | 17 +++++++----------
 test/sync.js | 15 ++++++---------
 2 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/backbone.js b/backbone.js
index b064107..7da3a57 100644
--- a/backbone.js
+++ b/backbone.js
@@ -279,8 +279,7 @@
         if (success) success(model, resp);
       };
       options.error = wrapError(options.error, model, options);
-      (this.sync || Backbone.sync).call(this, 'read', this, options);
-      return this;
+      return (this.sync || Backbone.sync).call(this, 'read', this, options);
     },
 
     // Set a hash of model attributes, and sync the model to the server.
@@ -297,8 +296,7 @@
       };
       options.error = wrapError(options.error, model, options);
       var method = this.isNew() ? 'create' : 'update';
-      (this.sync || Backbone.sync).call(this, method, this, options);
-      return this;
+      return (this.sync || Backbone.sync).call(this, method, this, options);
     },
 
     // Destroy this model on the server. Upon success, the model is removed
@@ -312,8 +310,7 @@
         if (success) success(model, resp);
       };
       options.error = wrapError(options.error, model, options);
-      (this.sync || Backbone.sync).call(this, 'delete', this, options);
-      return this;
+      return (this.sync || Backbone.sync).call(this, 'delete', this, options);
     },
 
     // Default URL for the model's representation on the server -- if you're
@@ -522,8 +519,7 @@
         if (success) success(collection, resp);
       };
       options.error = wrapError(options.error, collection, options);
-      (this.sync || Backbone.sync).call(this, 'read', this, options);
-      return this;
+      return (this.sync || Backbone.sync).call(this, 'read', this, options);
     },
 
     // Create a new instance of a model in this collection. After the model
@@ -543,7 +539,8 @@
         coll.add(nextModel);
         if (success) success(nextModel, resp);
       };
-      return model.save(null, options);
+      model.save(null, options);
+      return model;
     },
 
     // **parse** converts a response into a list of models to be added to the
@@ -1024,7 +1021,7 @@
     }
 
     // Make the request.
-    $.ajax(params);
+    return $.ajax(params);
   };
 
   // Helpers
diff --git a/test/sync.js b/test/sync.js
index 4d60dbf..b219f6e 100644
--- a/test/sync.js
+++ b/test/sync.js
@@ -1,14 +1,11 @@
 $(document).ready(function() {
 
-  module("Backbone.sync");
-
-  // Variable to catch the last request.
-  window.lastRequest = null;
-
-  // Stub out jQuery.ajax...
-  $.ajax = function(obj) {
-    lastRequest = obj;
-  };
+  module("Backbone.sync", {setup : function() {
+    window.lastRequest = null;
+    $.ajax = function(obj) {
+      lastRequest = obj;
+    };
+  }});
 
   var Library = Backbone.Collection.extend({
     url : function() { return '/library'; }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list