{"pull_request":{"state":"closed","merged_by":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/88e66469431b52ecccb22a51eca1a221?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"88e66469431b52ecccb22a51eca1a221","url":"https://api.github.com/users/peritus","login":"peritus","id":11022},"deletions":1,"updated_at":"2011-10-29T18:15:38Z","comments":1,"closed_at":"2011-10-29T18:15:38Z","base":{"ref":"master","user":{"avatar_url":"https://secure.gravatar.com/avatar/984df9bc1103ee70b636c87f414411a6?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","gravatar_id":"984df9bc1103ee70b636c87f414411a6","url":"https://api.github.com/users/documentcloud","login":"documentcloud","id":93383},"repo":{"name":"backbone","pushed_at":"2011-10-29T18:15:37Z","fork":false,"master_branch":null,"homepage":"http://documentcloud.github.com/backbone/","clone_url":"https://github.com/documentcloud/backbone.git","updated_at":"2011-10-29T18:15:37Z","open_issues":137,"language":"JavaScript","forks":549,"svn_url":"https://svn.github.com/documentcloud/backbone","private":false,"url":"https://api.github.com/repos/documentcloud/backbone","owner":{"avatar_url":"https://secure.gravatar.com/avatar/984df9bc1103ee70b636c87f414411a6?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","gravatar_id":"984df9bc1103ee70b636c87f414411a6","url":"https://api.github.com/users/documentcloud","login":"documentcloud","id":93383},"html_url":"https://github.com/documentcloud/backbone","description":"Give your JS App some Backbone with Models, Views, Collections, and Events","size":1832,"id":952189,"git_url":"git://github.com/documentcloud/backbone.git","watchers":4340,"created_at":"2010-09-30T19:41:28Z","ssh_url":"git@github.com:documentcloud/backbone.git"},"label":"documentcloud:master","sha":"41e470321deea9c30c1dd0327dc7ce312ae7c31d"},"diff_url":"https://github.com/documentcloud/backbone/pull/686.diff","commits":1,"head":{"ref":"patch-1","user":{"avatar_url":"https://secure.gravatar.com/avatar/88e66469431b52ecccb22a51eca1a221?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"88e66469431b52ecccb22a51eca1a221","url":"https://api.github.com/users/peritus","login":"peritus","id":11022},"repo":{"name":"backbone","pushed_at":"2011-10-24T14:55:47Z","fork":true,"master_branch":null,"homepage":"http://documentcloud.github.com/backbone/","clone_url":"https://github.com/peritus/backbone.git","updated_at":"2011-10-24T14:55:49Z","open_issues":0,"language":"JavaScript","forks":0,"svn_url":"https://svn.github.com/peritus/backbone","private":false,"url":"https://api.github.com/repos/peritus/backbone","owner":{"avatar_url":"https://secure.gravatar.com/avatar/88e66469431b52ecccb22a51eca1a221?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"88e66469431b52ecccb22a51eca1a221","url":"https://api.github.com/users/peritus","login":"peritus","id":11022},"html_url":"https://github.com/peritus/backbone","description":"Give your JS App some Backbone with Models, Views, Collections, and Events","size":136,"id":2636822,"git_url":"git://github.com/peritus/backbone.git","watchers":1,"created_at":"2011-10-24T14:53:19Z","ssh_url":"git@github.com:peritus/backbone.git"},"label":"peritus:patch-1","sha":"87760e1e1e4d3ad5e85914df0c529f274aa08752"},"url":"https://api.github.com/repos/documentcloud/backbone/pulls/686","additions":1,"merged":false,"body":"This is a patch for #592, my motivation is similar to the original report there.\r\n\r\nI want to `PUT` and `POST` data to my service with a custom Content-Type header (`application/mycompany+json` in this case), by overriding the sync method of the respective model.\r\n\r\n```javascript\r\nvar MyModel;\r\nMyModel = Backbone.Model.extend({\r\n  sync: function(method, model, options) {\r\n    return Backbone.sync(method, model, _.extend({\r\n      contentType: \"application/mycompany+json\"\r\n    }));\r\n  }\r\n});\r\n```\r\n\r\nI don't want to copy most of Backbone.sync to my own model to keep things DRY. Not all my models use the same content type, hence using jQuery's global ajaxSetup doesn't work.\r\n\r\nThanks for the great code!\r\n\r\n-----\r\n\r\nWorkaround:\r\n\r\n```javascript\r\nvar MyModel;\r\nMyModel = Backbone.Model.extend({\r\n  sync: function(method, model, options) {\r\n    return Backbone.sync(method, model, _.extend({\r\n      headers: {\r\n        \"Content-Type\": \"application/mycompany+json\"\r\n      }\r\n    }));\r\n  }\r\n});\r\n```","merged_at":null,"html_url":"https://github.com/documentcloud/backbone/pull/686","issue_url":"https://github.com/documentcloud/backbone/issues/686","review_comments":0,"_links":{"comments":{"_href":"https://api.github.com/repos/documentcloud/backbone/issues/686/comments"},"html":{"_href":"https://github.com/documentcloud/backbone/pull/686"},"review_comments":{"_href":"https://api.github.com/repos/documentcloud/backbone/pulls/686/comments"},"self":{"_href":"https://api.github.com/repos/documentcloud/backbone/pulls/686"}},"number":686,"title":"Backbone.sync: Give options.contentType precedence over hardcoded value","mergeable":true,"id":427693,"patch_url":"https://github.com/documentcloud/backbone/pull/686.patch","changed_files":1,"created_at":"2011-10-24T15:05:26Z"},"action":"closed","number":686}