Skip to content

Instantly share code, notes, and snippets.

@mockee
Created October 31, 2012 09:14
Show Gist options
  • Save mockee/3985999 to your computer and use it in GitHub Desktop.
Save mockee/3985999 to your computer and use it in GitHub Desktop.
Override Backbone.sync
define('mod/bbsync', [
'underscore'
, 'mod/ajax'
], function(_, Ajax) {
function sync(method, model, options) {
var url = model.url, data
url = _.isFunction(url) ? model.url() : url
data = method === 'create' || method === 'update'
? model.toJSON() : {}
method = Ajax.methodMap[method]
return Ajax.request(method, url, data, options, 'json')
}
return sync
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment