Skip to content

Instantly share code, notes, and snippets.

@jordan-brough
Created December 3, 2010 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordan-brough/7d0a00c2c03e5a053144 to your computer and use it in GitHub Desktop.
Save jordan-brough/7d0a00c2c03e5a053144 to your computer and use it in GitHub Desktop.
diff --git a/backbone.js b/backbone.js
index 4217e62..bdc6682 100644
--- a/backbone.js
+++ b/backbone.js
@@ -906,11 +906,11 @@
// Useful when interfacing with server-side languages like **PHP** that make
// it difficult to read the body of `PUT` requests.
Backbone.sync = function(method, model, success, error) {
var type = methodMap[method];
var modelJSON = (method === 'create' || method === 'update') ?
- JSON.stringify(model.toJSON()) : null;
+ JSON.stringify(model.toParams ? model.toParams() : model.toJSON()) : null;
// Default JSON-request options.
var params = {
url: getUrl(model),
type: type,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment