This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do (Backbone) -> | |
Backbone._sync = Backbone.sync | |
Backbone.sync = (method, entity, options={}) -> | |
_.defaults options, | |
beforeSend: _.bind( methods.beforeSend, entity ) | |
complete: _.bind( methods.complete, entity ) | |
if method is 'create' or method is 'update' or method is 'put' or method is 'delete' | |
options.headers ?= {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Backbone._sync = Backbone.sync | |
Backbone.sync = (method, model, options) -> | |
if method is 'create' or method is 'update' or method is 'put' or method is 'delete' | |
options.headers ?= {} | |
options.headers["X-CSRF-Token"] = $("meta[name='csrf-token']").attr 'content' | |
return Backbone._sync(method, model, options); |