[Pkg-javascript-commits] [backbone] 43/281: Needs testing, but fixes #686, fixes #592, and probably others -- allow you to override any $.ajax options.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:01:54 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 8478567ecb64d8bc26cc2d10f456420f5e6368df
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Sat Oct 29 14:15:33 2011 -0400

    Needs testing, but fixes #686, fixes #592, and probably others -- allow you to override any $.ajax options.
---
 backbone.js | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/backbone.js b/backbone.js
index 6bc33bc..f45feb6 100644
--- a/backbone.js
+++ b/backbone.js
@@ -1053,18 +1053,15 @@
     var type = methodMap[method];
 
     // Default JSON-request options.
-    var params = _.extend({
-      type:         type,
-      dataType:     'json'
-    }, options);
+    var params = {type : type, dataType : 'json'};
 
     // Ensure that we have a URL.
-    if (!params.url) {
+    if (!options.url) {
       params.url = getUrl(model) || urlError();
     }
 
     // Ensure that we have the appropriate request data.
-    if (!params.data && model && (method == 'create' || method == 'update')) {
+    if (!options.data && model && (method == 'create' || method == 'update')) {
       params.contentType = 'application/json';
       params.data = JSON.stringify(model.toJSON());
     }
@@ -1072,7 +1069,7 @@
     // For older servers, emulate JSON by encoding the request into an HTML-form.
     if (Backbone.emulateJSON) {
       params.contentType = 'application/x-www-form-urlencoded';
-      params.data        = params.data ? {model : params.data} : {};
+      params.data = params.data ? {model : params.data} : {};
     }
 
     // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
@@ -1092,8 +1089,8 @@
       params.processData = false;
     }
 
-    // Make the request.
-    return $.ajax(params);
+    // Make the request, allowing the user to override any Ajax options.
+    return $.ajax(_.extend(params, options));
   };
 
   // Helpers

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