Skip to content

Instantly share code, notes, and snippets.

@nhajratw
Created January 24, 2012 04:04
Show Gist options
  • Save nhajratw/1667727 to your computer and use it in GitHub Desktop.
Save nhajratw/1667727 to your computer and use it in GitHub Desktop.
Getting Backbone to communicate with XML services using CoffeeScript
# Keep track of the original sync method so we can
# delegate to it at the end of our new sync.
originalSync = Backbone.sync
# Our new overriding sync with dataType and ContentType
# that override the default JSON configurations.
Backbone.sync = (method, model, options) ->
options = _.extend(options,
dataType: 'xml'
contentType: 'application/xml'
processData: false
)
originalSync.apply(Backbone, [ method, model, options ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment