Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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