[Pkg-javascript-commits] [backbone] 185/281: Fixes #783 -- adds a 'sync' event, fired whenever a successful call has been made to update the server.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:02:10 UTC 2014


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

js pushed a commit to tag 0.9.0
in repository backbone.

commit 8c03df50c354b694b45ce266e84ed7fc749ce01b
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Fri Jan 13 10:57:51 2012 -0500

    Fixes #783 -- adds a 'sync' event, fired whenever a successful call has been made to update the server.
---
 backbone.js | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/backbone.js b/backbone.js
index a1b228b..04e9507 100644
--- a/backbone.js
+++ b/backbone.js
@@ -272,7 +272,11 @@
       var success = options.success;
       options.success = function(resp, status, xhr) {
         if (!model.set(model.parse(resp, xhr), options)) return false;
-        if (success) success(model, resp, xhr);
+        if (success) {
+          success(model, resp);
+        } else {
+          model.trigger('sync', model, resp, options);
+        }
       };
       options.error = Backbone.wrapError(options.error, model, options);
       var method = this.isNew() ? 'create' : 'update';
@@ -288,7 +292,11 @@
       var success = options.success;
       options.success = function(resp) {
         model.trigger('destroy', model, model.collection, options);
-        if (success) success(model, resp);
+        if (success) {
+          success(model, resp);
+        } else {
+          model.trigger('sync', model, resp, options);
+        }
       };
       options.error = Backbone.wrapError(options.error, model, options);
       return (this.sync || Backbone.sync).call(this, 'delete', this, options);
@@ -539,7 +547,11 @@
       var success = options.success;
       options.success = function(nextModel, resp, xhr) {
         coll.add(nextModel, options);
-        if (success) success(nextModel, resp, xhr);
+        if (success) {
+          success(nextModel, resp);
+        } else {
+          nextModel.trigger('sync', model, resp, options);
+        }
       };
       model.save(null, options);
       return model;

-- 
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