Skip to content

Instantly share code, notes, and snippets.

@Layzie
Created December 17, 2013 05:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Layzie/8000427 to your computer and use it in GitHub Desktop.
Save Layzie/8000427 to your computer and use it in GitHub Desktop.
`beforeSend` was changed at Zepto1.1.1. So `Backbone.sync` is now broken. This patch will fix, maybe. see https://github.com/madrobby/zepto/issues/878
diff --git a/backbone.js b/backbone.js
index 2171292..fd83e56 100644
--- a/backbone.js
+++ b/backbone.js
@@ -1162,8 +1162,12 @@
params.type = 'POST';
if (options.emulateJSON) params.data._method = type;
var beforeSend = options.beforeSend;
- options.beforeSend = function(xhr) {
- xhr.setRequestHeader('X-HTTP-Method-Override', type);
+ options.beforeSend = function(xhr, settings) {
+ if (settings && settings.headers) {
+ settings.headers['X-HTTP-Method-Override'] = type;
+ } else {
+ xhr.setRequestHeader('X-HTTP-Method-Override', type);
+ }
if (beforeSend) return beforeSend.apply(this, arguments);
};
}
@Layzie
Copy link
Author

Layzie commented Dec 18, 2013

This problem has been fixed at this commit in zepto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment